ui-dialog with forms
ui-dialog with forms
Hello there!
I'm new to jquery, i was having a happy begining when i had a little
problem, i wanted a form inside a dialog, so i decided to use ui-
dialog to get it working, i created a simple form with only a text
field, then i used a dialog button event to submit it with ajax using
jquery.form plugin. Well.. everything went fine at first glance, i
fill the form, submit it, get a response, close the dialog, and
everyhing was ok. Then i opened the dialog again, filled the form, but
in this case, form elements aren't reachable with exactly the same
selectors of first time. when i tried to get the input value for
validation it was just an empty string, even if i write in the input
box. i dont know if i'm missing something. I tried do it without
closing the dialog, and i could submit the form many times without any
problem. the problem seems to be when closing and then opening the
dialog again.
If someone could help or give me a clue, i'll apreciate :-)
Regards,
Inside
here goes some code:
$("#new-folder-dialog").dialog({
autoOpen: false,
bgiframe: true,
modal: true,
buttons: {
'Create Folder': function() {
var value = $("#create-folder-form input[name=name]").val();
if(value.length == 0) {
alert('Please, introduce the name of a new folder');
return;
}
$("#create-folder-form").ajaxSubmit({
type: 'POST',
success: function(response, status) {
alert(response);
$("#create-folder-form").clearForm();
$("#browser-panel").load("/bizcenter/stored_files/
view_category/", {}, setupBrowserBehavior);
}
});
},
'Cancel': function() {
$(this).dialog('close');
}
}
});
$("#new-folder").click(function() {
$("#new-folder-dialog").dialog("open");
});