开发者

Jquery not working fine with out an alert box

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜