0

Possible Duplicate:
How to wait until an element exists?

I'm using a jquery plugin to show a modal dialog. the content of that dialog is loaded via ajax. the outermost div of that content is msg . As the div msg doesn't exist when the page is loaded (modal dialog is shown later by clicking a button), I can't apply jquery on that div. e.g. $(".msg").some_Action() doesn't work.

I know a bit about the on or live(deprecated now). But how can I apply it here? or any other solution?

NB: ajax request is handled via the plugin itself, so I can't(or maybe won't) write something on success of the ajax request

Community
  • 1
  • 1
sha256
  • 3,029
  • 1
  • 27
  • 32
  • What plugin are you using? Maybe this plugin supports callback `success` function? – maxwell Oct 30 '12 at 08:26
  • I'm using http://hasnath.net/superdialog-plugin-for-jquery.php plugin. ajax is handled in side the plugin, so is `success` function. :( – sha256 Oct 30 '12 at 08:28
  • do you have dialog box in dom when document get ready. – Jai Oct 30 '12 at 08:36
  • dialog box loaded later using ajax @JaiPSah – sha256 Oct 30 '12 at 08:53
  • then if you want to open that dialog box with any other link then it has to be availble in the dom so that dialog can be called via jq or js. – Jai Oct 30 '12 at 08:57
  • The good style would be to create custom callback sucess function in plugin options and call it from plugin. – maxwell Oct 30 '12 at 10:04

1 Answers1

0
$("body").on('// some actions e.g ready or click', '// element on which action is to be implemented e.g. button', function() {
// some functions here e.g. show() and hide()
});
Heart
  • 508
  • 1
  • 3
  • 14
  • oh man as you want to open dialog on click of button so change .msg with the class or id of that button! – Heart Oct 30 '12 at 08:29