1

Bootstrap has a modal-method with a remote option. I want to perform some actions on the content that has been loaded by Jquery/Bootstrap. (e.g., scan for specific classes and replace content on the fly).

Is there an 'onloaded' option in the modal() method?

$('#someplaceholder'.modal({
    remote: "data/whatever/123",
    onloaded: function() {
    // perform some substitution,...
        },
});

I solve this now by using a setTimeout() function; but this is not an elegant way.

madth3
  • 7,275
  • 12
  • 50
  • 74

1 Answers1

0

Bootstrap modal 'loaded' event on remote fragment

There is no loaded event and it doesn't look like bootstrap is providing a fix for this. You can do the following.

$('#someplaceholder').modal().find('.modal-body').load("data/whatever/123", function (data) {
    //do stuff with returned data here
});
Community
  • 1
  • 1
marcellscarlett
  • 388
  • 2
  • 17
  • Good luck if you have 20 modals :) I am sure the bootstrap guys not have implemented an `onLoaded` event since it would be redundant. You already have the nessecary "infrastructure" in jQuery, and if you need the functionality you can add this by 2 or 3 lines of code. Better than tweak the entire modal initialization. – davidkonrad Oct 04 '13 at 14:16