Monday, 15 August 2011

jquery - Using external script inside load callback with dialog? -



jquery - Using external script inside load callback with dialog? -

i hope can explain properly. creating jquery dialogue box content loaded html file. dialogue box contains form need perform additional js functions. problem running into, none of html/selectors exist in dom until click #image_edit jquery upload script not working. can see, invoking upload function on .load callback, doesn't work. there better/proper way this?

edit : after moving .dialog , remote functions within load() callback, working expected.

uploadinterface.js

(function($) { $(function(//removed, not needed//) { //upload functions// }); })(window.jquery);

uploadsetup.js

(function($) { $(function(//removed, not needed//) { //upload functions// }); })(window.jquery);

dialogue.js

$(function(){ $('#image_edit').click(function() { $(".upload_div").load('../dialogues/content.html #upload_window', function() { $.getscript("js/uploadinterface.js"); //added remote script here// $.getscript("js/uploadsetup.js"); //added remote script here// }).fadeto("slow", 1).dialog({ title: "upload image", width: "320px", position: { my: 'top', at: 'top+150' }, resizable: false, draggable: false, modal: true, show: "fadein", hide: "fadeout", create: function(event, ui) { var widget = $(this).dialog("widget"); $(".ui-dialog-titlebar-close span", widget) .removeclass("ui-icon-closethick") .addclass("ui-icon-close-custom"); } }); }); });

to load scripts in jquery should utilize $.getscript() in load callback function have $.getscript() script execute whatever functions want.

$(".upload_div").load('../dialogues/content.html #upload_window', function() { $.getscript( "uploadinterface.js" ) })... ... ...

jquery html jquery-ui-dialog anonymous-function

No comments:

Post a Comment