I hope I can explain this properly. I am creating a JQuery dialogue box where the content is loaded from an HTML file. This dialogue box contains a form with which I need to perform additional JS functions. The problem I am running into, is that none of the HTML/selectors exist in the DOM until I click #image_edit so my JQuery upload script is not working.
As you can see, I am invoking the upload function on the .load callback, but it doesn't work. Is there a better/proper way to do this?
EDIT :
After moving the .dialog and remote functions inside the load() callback, everything is working as expected.
uploadInterface.js
(function($) {
$(function(//removed, was not needed//) {
//upload functions//
});
})(window.jQuery);
uploadSetup.js
(function($) {
$(function(//removed, was 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 an 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");
}
});
});
});