Javascript in ajax request - Boxy handling - Patch

35 views
Skip to first unread message

PiTiLeZarD

unread,
Jan 25, 2011, 9:51:26 AM1/25/11
to boxy
Hi,

I just pointed out an issue while using javascript inside the return
of an ajax query. The javascript was executed before the display was
done, so I propose a patch that works for me :

(the patch basically launch javascripts after the boxy alert is
displayed, this way all DOM is updated and fully usable)

--- a/public/js/jquery.boxy.js Tue Jan 25 12:32:20 2011 +0100
+++ b/public/js/jquery.boxy.js Tue Jan 25 15:44:28 2011 +0100
@@ -149,7 +149,14 @@
url: url, type: 'GET', dataType: 'html', cache: false,
success: function(html) {
html = jQuery(html);
if (options.filter) html = jQuery(options.filter,
html);
- new Boxy(html, options);
+
+ /* display only html */
+ new Boxy(html[0], options);
+
+ /* execute all scripts afterwards */
+ for (var i = 1; i < html.length; i++) {
+ $.globalEval($(html[i]).html());
+ }
}
};

Reply all
Reply to author
Forward
0 new messages