Please ignore if I am asking a repeated or common question.
Jquery is working fine if i have an alert in the code. Example:var selectedEvent = jQuery("#DemoEvents").jqGrid('getGridParam','selrow');
var imagePath = jQuery("#DemoEvents").getCell(selectedEvent, 9开发者_StackOverflow中文版);
var locationArr = imagePath.split("rel");
var evtId = jQuery("#DemoEvents").getCell(selectedEvent, 0);
**alert(evtId);**
var anchorId = jQuery("#DemoEvents").getCell(selectedEvent, 7);
jQuery('#tr_anchorId .FormElement').val(anchorId);
jQuery("#tr_anchorId .FormElement option[value='"+evtId+"']").remove();
is working fine... and....
var selectedEvent = jQuery("#DemoEvents").jqGrid('getGridParam','selrow');
var imagePath = jQuery("#DemoEvents").getCell(selectedEvent, 9);
var locationArr = imagePath.split("rel");
var evtId = jQuery("#DemoEvents").getCell(selectedEvent, 0);
**//alert(evtId);**
var anchorId = jQuery("#DemoEvents").getCell(selectedEvent, 7);
jQuery('#tr_anchorId .FormElement').val(anchorId);
jQuery("#tr_anchorId .FormElement option[value='"+evtId+"']").remove();
is not working. any ideas please give.
The only reason it should not be working is because there is an AJAX call in your method.
Placing an alert
on this snippet gives time for that AJAX call to fetch your data. Otherwise it won't work because the snippet runs out before your AJAX call returns.
If there is an AJAX Call then you should ideally be writing the rest of the code in its call back method and this would solve the issue.
P.S: I was wrong about getCell
. Its a jqGrid method. Sorry.
精彩评论