If you get the data and then use it in the dialog, it will bind the
simplemodal-close class. Otherwise, you have to do it manually in the
onShow callback.

The following will auto-bind:

$('#mylink').click(function (e) {
        e.preventDefault();
        // load the contact form using ajax
        $.get("data/test.html", function(data){
                // create a modal dialog with the data
                $.modal(data); // contains a button with simplemodal-close class
        });
});

If you are opening the dialog and then adding the content, you'll need
to do something like:

$.modal(data, {onShow:  function (dialog) {
  $(".simplemodal-close", dialog.data).click(function (e) {
    e.preventDefault();
    $.modal.close();
  });
}});

Hope that helps.

-Eric


On Mar 25, 8:49 am, dbonneville <doug.bonnevi...@gmail.com> wrote:
> I have an include that contains all the HTML for the modal dialogue
> content. In the HTML, I also have a close button with the class
> "simplemodal-close" attached to it, which triggers the close function.
> That works great.
>
> However, I decided to load the snippet via jquery.get. It loads in
> just fine. But now, the close button with the "simplemodal-close"
> class on it will now not trigger the event.
>
> Is this because the button with the class on it was loaded AFTER the
> script was loaded? How can I make the button work?
>
> Nothing in the HTML include or HTML snipped loaded through "get" are
> any different. When I compare pages in Firebug, the include version
> and the get version are identical in all respects.
>
> What do I need to do to the button AFTER its loaded via jquery.get to
> make it aware that it has the class on it?

Reply via email to