lw-bobbimartin / simplemodal

Automatically exported from code.google.com/p/simplemodal
0 stars 0 forks source link

Push data for "persist" option before calling custom onClose callback #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I may be missing the obvious "correct" way to do this so please give me any
hints if you have any.

Desired usage (confirm with option):
 * Modal with some fields from a larger HTML form
 * User fills in this field and "submits" the form 
 * Fields are push back to the larger form
 * Form submits
Legacy reasons prevent me from bring the whole form into the pop-up.

Problem with 1.3b1 that prevent desired usage.
 * onClose call back occurs before data is pushed back into the form
I'm unaware of a "real" onClose callback that happens after the data has be
fully pushed back into the page. Where do I put my forms[0].submit() ?

Suggested solution; push the data back twice. Additionally do it before
calling the the onClose callback.

In Code this could be inserting this block before calling the onClose event.
if (this.dialog.parentNode && this.opts.persist) {
 this.dialog.data.appendTo(this.dialog.parentNode).hide();
}

Original issue reported on code.google.com by cavi...@gmail.com on 18 Jun 2009 at 8:23

GoogleCodeExporter commented 9 years ago
cavidae,

It is probably a confusion of terms/semantics, but basically the onOpen and 
onClose
are used to manually open and close the dialog.

So, in your case, I would suggest handling the submit and processing in the 
onShow
callback and then calling $.modal.close() when you are ready to really close the
dialog...leaving only closing animations for the onClose callback.

HTH

Original comment by emartin24 on 4 Dec 2009 at 7:44