开发者

ui.dialog - returning a value back to the dialog for its public methods to act on

After spending a few days surfing for solutions here and elsewhere on the net, it seems asking my question directly has become my last and only option. My website is all ajax driven; I have funcs that create and load remote content in lightboxes, cluetips, iframes (ACD) etc...

Where loading forms is required I've decided to use a ui.dialog to expose a Captcha ajaxForm as a 1st step; which also calls a back-end script to do RBL checking on remote host.

So if the RBL-check clears and the captcha is correct, i have the ajaxForm.postResponse populate a message in the dialog. Now, the ajaxForm itself could (if OK) close the dialog and open a new modal; but that would take control of the process away from the caller and require the ajaxForm know the callers' intention (what content and what mode - tip,lightbox,...). I just want the captcha form to perform the test and return a binary value that it can pass on the the caller.

Is there a way for the callee to tell the caller (the dialog instance) to be able to then continue loading the actual form its fronting for. E.g. jQuery.fa开发者_JS百科cebox({ ajax: someUrl });

The dialog would need to be able to process some returned value from the ajaxForm. I've looked at ui.dialog's public methods in the options, I've looked at extending options, I've looked at the params associated with buttons (e,ui). All to no avail.

After scouring the net I have yet to find anybody who has published way to pass the dialog a returned value that it can act on (in b4close, or close, or anywhere FTM)

Just this AM, i realized maybe i could be clever and have the ajaxForm.postResponse insert something into the dialog that upon completion the dialog could test for (say, the OK image). So the dialog would act on the contents of the markup instead of an actual returned value. What a kludge.

Does anyone know of a way to pass a value back to the dialog after its instantiated? I discovered that $("#myDialog).data can be 'seen' by $("#myDialog).dialog so would the data vector be a possible solution? Set myDialog.data('retVal', 'false') and then have postResponse change it to true if OK and letting the dialog then test that var in close()/beforClose()?

Or, what about $( '#myDialog' ).dialog( 'option', 'retVal', false ); Can the ajaxForm.postResponse alter that option after the dialog's creation.

Are there any other ways to do this? TIA


answering my own question - you can use the .data vector to pass information between the dialog instance and the form or whatever in the callee. Works quite nicely. Still do not know if this is the best approach, but it works. E.g. in the dialog.config var dest = './Contact/contact-form.info.php'; var url = this.href; var myDialog = $('#dialog'); myDialog.data('retVal', 'false'); myDialog.data('dest', dest);

if everything goes ok in the postResponse of the ajaxForm then set $('#dialog').data('retVal', true ); and in dialog.beforeClose() test the value and act accordingly beforeclose: function(event, ui) if( $(this).data('retVal')) { jQuery.facebox({ ajax: $(this).data('dest') }); } });

Surprised I found no mention of this anywhere else on the net. Probably because most ppl are using ui-dialog in more complex ways.

Anyhow, there you have it and there it is

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜