dinesh
Posts: 8
|
Posted: 12/05/2011, 8:18 PM |
|
Event Delegation Problem
My first page is "contact_list.php" which shows a list of contacts. I have a button called "ShowContact" which opens a modal dialog
and displays the second page "contact_maint.php", which is basically a form that posts back to itself. Validation is processed when
the form is posted back to itself, and upon successful validation, the database is updated.
This works fine the first time the dialog box is displayed. When the contact form is submitted, the dialog is reloaded (updated)
with the posted form. The reloaded form does not observe the event. I know this has got something to do with Event Delegation. I've
tried using .delegate and the .live, but nothing seems to work.
The contact_list.php and contact_maint.php
is generated using CodeCharge and works fine by itself. I'm trying to make the
contact_maint.php page into a modal dialog
Any advice anyone?
My js library includes jquery-1.7.1, jquery-ui-1.8.16, prototype.js, ajaxpanel.js, dialog.js
Code Snippet
--------------------------------------------------------------------------------
document.observe("dom:loaded", function() {
Event.observe(document.body, "click", function(event) {
if(Event.element(event).id=="ShowContact"){
dispDialog("contact_maint.php");
}
})
});
function dispDialog(url) {
Dialogs.load();
var contact = new Dialog({
title:"Add Contact",
ajax:{
url:url,
options:{
parameters:{
height:"auto"
},
onComplete:function(t){
Event.observe("contact","submit", function(event){
event.preventDefault();
$("contact").request({
onComplete: function(t){
var retval = t.responseText;
if(retval.match("Error")){
$("contact").update(retval);
}else{
Dialogs.close()
Event.stop(event);
}
}
});
})
}
}
}
})
contact.open();
}
--------------------------------------------------------------------------------
|
|
|
mamboBROWN
Posts: 1713
|
Posted: 12/10/2011, 3:59 PM |
|
dinesh,
Have you been able to resolve this challenge yet?
|
|
|
|