开发者

Ajax calls in Widgets in jQuery Dashboard

I am using the jQuery Dashboard plugin to display MySql table information. I have within these widgets buttons for each mysql result to display a form. The button performs an ajax call to pass in the form id and then retrieve the styled form information to be displayed in a jQuery dialog. The issue is that 开发者_运维百科the first time visiting the dashboard and trying to click a button requires multiple clicks for the form to be retrieved. I have several widgets in the dashboard that use this technique (3 to be exact) and it just so happens to take 2 clicks before the 3rd will return the form. Could this be due to the button instances in different widgets? I thought so, and as a result made different classes for each button with same ajax code. The problem, however, persists. This is an extraordinarily annoying bug that I CANNOT figure out and have been trying to for 4 DAYS on this 1 bug alone. Below is my ajax code:

$(".view_all").click(function(){ var form_id = $(this).attr("id"); $.ajax({ type: "GET", url: "form.php", data: "fid="+form_id, beforeSend: function(){ $("#loading").show(); }, success: function(msg){ $("#pop_container").html(msg); $("#pop_container").dialog({ autoOpen: false, height: 750, width: 950, modal: true, closeOnEscape: false }); $("#pop_container").dialog("open"); $("#loading").hide();

} }); return false; });

My apologies for the code not being formatted well. I tried but it didnt work.

Anyway, any help on this would be extremely helpful. Thanks!


As i previously said, a live example would have helped but i still took a look at this code and everything seemed pretty alright, assuming you're ajax calls always return what it should return (did you verify with firebug or somethin?). You should put this piece of your code in the dom ready function:

                $("#pop_container").dialog({ 
                    autoOpen: false, 
                    height: 750, 
                    width: 950, 
                    modal: true, 
                    closeOnEscape: false 
                }); 

Instead of setting this in the callback. So you just have to call $('#pop_container').dialog('open'); in the callback. Now if this is not enough, and it shouldn't be enough, you can manually trigger a click in jQuery ($('.view_all').trigger('click')) but this is not really "clean". Don't know if this helps but i can't do more without completely understanding whats going on :P

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜