Vissu
Vissu

Reputation: 2043

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);  
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.

Upvotes: 2

Views: 427

Answers (1)

codeandcloud
codeandcloud

Reputation: 55288

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.

Upvotes: 1

Related Questions