Ok getting my feet wet with mvc. I am trying to build a user profile type page. The page is made up of several sections, each loaded via a partial view.
I want to be able to edit each section individually inside of an jQuery-UI modal dialog. I have this all working properly(incduding loading the Edit views via ajax into the modal and submitting the changes.)
My problem is that after any ajax call my jQuery-UI dialogs stop working so I am unable to close or open a dialog.
I can, of course, fix things like button clicsk with the .live method but I cant figure out the best way to get the jQuery-UI items to continue working.
What is the best way to go about this? I guess I am confused as to what happens to previously loaded jQuery plugins after an ajax call. Should I be able to reference elements on my ajax loaded content from my main page?
EDIT: Ok...heres some code to show whats happening....
user click the edit button on the user info section
$('#editInfo').live("click", function () {
dialogInit(450, 550, 'User Information');
$('#dialog').dialog('open')
$.ajax({
type: 'GET',
url: '../info/edit',
data: {},
success: function (response) {
$('#dialog').html(response); //loads the partial edit view into the dialog div...works fine to here.
}
});
return false;
});
After this happens I have a modal on the screen with a save button. When the save button is clicked I post my ajax form which calls this JS function on success...
function infoUpdate(response) {
dialogInit(450, 550, 'User Information');
$('#dialog').dialog('close');
$('#info').html(response);
}
This loads the new User info partial view into the appropriate div on the main page...works fine...
The problem here is that the dialog is not closed...so the reference to it seems to be lost even though I am reinitializing it with my dialogInit function...which looks like this...
function dialogInit(height, width, title) {
$('#dialog').dialog({
autoOpen: false,
modal: true,
draggable: false,
resizable: false,
height: height,
width: width,
title: title
});
}
EDIT 2:
The above code also causes my ajax form to be posted multiple times...an additional time every time I click the submit button...not good