I've faced a little problem with dhtmlxGrid. When I use this:
myGrid.selectRow(someRowId);
the event attached still doesn't run
myGrid.attachEvent("onRowSelect", function(id){
. . .
});
How can I make it works? Is it possible to simulate a click on the row?
Please, try to enable the second attribute of the selectRow() method:
myGrid.selectRow(rowIndex,true);
It will cause the onRowSelect event to occur.
Related
When I add a new row kendo ui grid it does not move to next page even I set page number dynamically.
But when there is a javaScrip alert it's working fine.
Has any one faced this issue before. Please suggest me a solution.
Thank you.
The problem is that when you add a new row there are a series of actions that happen in parallel and they are not immediate. If you try to move to the end but the row still is being created, if fails.
When you add an alert, you delay the fact of moving and creation now have time.
If you really need to do it, you can add a timeout (delay) it is not nice/clean but should work.
Do something like:
setTimeout(function() {
grid.page(3);
}, 500);
for introducing half second (500 ms) delay, should be enough.
We had sort of similar issue in IE - onchange fired twice with alert in the event handler. According to what you saying, it sounds like when the alert is NOT in you are getting correct behaviour. Review your code without having the alert in or post a fiddle. Below is an answer from Kendo support in regards to alerts while debugging. Do not use alerts with kendo to stay safe.
Basically this behavior is caused by using "alert" method for debugging purposes - please note that this is not recommended because it can lead to unexpected behavior when interacting with focusing elements. After replacing the "alert" method and with "debbuger" command or "console.log()" function the change event is working as expected - please check this screencast(http://screencast.com/t/7qIAdK6hZ5kD).
Hope it helps.
How could the example seen here
https://developers.google.com/chart/interactive/docs/php_example
be modified to load onclick? I tried doing this very thing with jQuery unsuccessfully.
the google.load() and google.setOnLoadCallback() should be called inside another function
which should be called onclick on div/button where ever you want .
Hope this helps you...
I have button with id = new which loads the new page
$("#new").click(function(){
$('#message_area').load('new.php');
});
There is a button in new.php which sends message to database. But i have a problem with it , it only works for first time when page loads if i navigate to some other links via ajax and again load new.php using above code then send button in new.php does not work i have to refresh the page then it works. I think its because the send button in new.php is added after DOM is created for first time .
Please help Thanks in advance ..
You will need to post more details of your markup for a more accurate answer, but the general idea is to use event delegation. Bind the event handler to an ancestor of the button that does not get removed from the DOM. For example:
$("#message_area").on("click", "#yourButton", function() {
//Do stuff
});
This works because DOM events bubble up the tree, through all of an elements ancestors. Here you are simply capturing the event higher up the tree and checking if it originated from something you are interested in (#yourButton).
See jQuery .on for more. Note that if you're using a version of jQuery below 1.7, you will need to use delegate instead.
//jquery >= v1.7
$("body").on('click', '#new', function(){
$('#message_area').load('new.php');
});
//jquery < v1.7
$("#new").live('click',function(){
$('#message_area').load('new.php');
});
$("#new").live("click", function(){
$('#message_area').load('new.php');
});
just realized this was deprecated-- should be using on instead.. my bad.
To manage dynamically created elements like this, you need to use .on() (jQuery 1.7 and above) or .delegate() (jQuery 1.4.3 and above) to assign the events. Seems everyone has beaten me to the code, but I'll post this for the links to the functions.
i'm facing a small issue with the fireevent. in one js file i'm firing the event like this: Ti.App.fireEvent('foo', {name:col});
in an other file i'm listening to the event.
tableimg.addEventListener('click',function(e){
if(e.source.backgroundColor==''){CreateTableWindow(1,e.source.id);}
else{
changeTheDinerStatus();
Ti.App.addEventListener('foo', function(data)
{
var ke=data.name;
alert(e.source.id+'###'+ke);
e.source.backgroundColor = ke;
});
}
});
so here is the problem, wen ever i'm firing the event the function in the listener is repeating itself.....
like this
wen clicked for the first time it runs once..1####FFF
wen the second table is clicked it goes
1####AAA
2####AAA
for the third time
1####BBB
2####BBB
3####BBB
this goes on like this for all the time....
I can't see your DOM structure in front of me, but I think, the main problem is, that you add an event listener on every click.
You should not do this.
If you need to solve the problem this way, you should remove the existing listener
element.removeEventListener('foo',spyOnUser,false)
Yesterday I was introduced to the CListView and could manage to display all the information i want about my records, and in the format i want. I have a 'create' button (add a new contact), which opens a modal pop up window with the corresponding fields. When this window is closed, i return to the CListView, and here is my issue: i've been trying to update the CListView (without any luck, clearly).
I believe it should be easy to update the clistview with this call: $.fn.yiiListView.update('CListViews's ID'), but i can't find the proper event that should trigger this call.
Next, i post what i would think is the relevant code:
Button
echo CHtml::ajaxButton ("Create",
CController::createUrl('/contacts/create'),
array('onclick'=>'
$("#createContact").dialog("open");
return false;',
'update'=>'#createContact'),
array('id'=>'showCreateContactDialog'));?>
CListView
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>new CArrayDataProvider($model->contacts, array('pagination'=>array('pageSize'=>5,),)),
'itemView'=>'_view',
'emptyText'=>'empty',
'template'=>"{items}\n{pager}",
'pagerCssClass'=>'page-number',
'id'=>'ajaxListView',
));?>
Any help is more than welcome!! Hope this helps someone eventually as well.
If I understand correctly, your problem is finding what to trigger the CListView update with (the JS update snippet you provide should work fine).
Probably the jQuery dialog event close is what you are looking for; it will get triggered after the dialog has been closed. Alternatively, there is also a beforeClose event that has the additional capability to prevent the dialog from closing.