nikku/jquery-bootstrap-scripting

Ajaxifying modal content after updating content via out-of-band ajax

tboyko opened this issue · 2 comments

Is there a way to trigger __ajaxify, or better yet, content-update, after updating some of the content in the modal window via out-of-band means?

Use case: I am using Rails3 remote functionality to place ajax calls to the server from within a modal. The server response updates some of the contents of the modal. This contents includes a.ajax elements. These are not being respected, however, as they haven't been ajaxified.

Bonus: I have custom JS that I've plugged in via the dialog2.closed listener which I'd like to also trigger.

If I understand correctly you want to trigger the dialog2.content-update event (which will ajaxify the new contents, apply markup changes (e.g. change the title) and focus the dialog. You can simply do so by using the jQuery trigger function.

var dialog = $("<div />").dialog2({...});

// trigger ajaxify/markup update functionality after you did custom updates to the dialogs contents. 
dialog.trigger("dialog2.content-update");

That did it. Thank you!