Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing code after modal-body is loaded #5169

Closed
Nerian opened this issue Sep 17, 2012 · 27 comments
Closed

Executing code after modal-body is loaded #5169

Nerian opened this issue Sep 17, 2012 · 27 comments
Labels

Comments

@Nerian
Copy link

Nerian commented Sep 17, 2012

I am using a modal with the remote option. I'd like to be able to execute some code once the modal-body is loaded.

Currently the only events we have available is show and shown. I tried using shown but loading the modal-body occurs after the shown event is fired.

How could I achieve this?

@qnal
Copy link

qnal commented Sep 18, 2012

Could you use the jQuery .change() functionality?

E.g.

$('.modal-body').change(
function() {alert('something'); // ?
});

@Nerian
Copy link
Author

Nerian commented Sep 18, 2012

According to the docs, it just works for elements such as input, textareas, etc.

http://api.jquery.com/change/

El 17/09/2012, a las 21:03, Kunal Das notifications@github.com escribió:

Could you use the jQuery .change() functionality?

E.g.

$('.modal-body').change(
function() {alert('something'); // ?
});


Reply to this email directly or view it on GitHub.

@andrewdeandrade
Copy link

Hey @Nerian,

Thanks for opening this issue! Unfortunately, it looks like it fails to pass the criteria neccessary for submitting to bootstrap. The following things are currently failing:

  • should include a jsfiddle/jsbin illustrating the problem if tagged with js but not a feature

For a full list of issue filing guidelines, please refer to the bootstrap issue filing guidelines.

thanks!

@Nerian
Copy link
Author

Nerian commented Sep 27, 2012

Sure, here it is.

http://jsfiddle.net/Qz6rA/

@Nerian
Copy link
Author

Nerian commented Oct 8, 2012

@koenpunt That last comment includes the jsfiddle :)

@koenpunt
Copy link
Contributor

koenpunt commented Oct 9, 2012

My bad, did run make haunt to see what it does and at first it showed me nothing, but now I see; it commented on all the issues..

@fat
Copy link
Member

fat commented Dec 21, 2012

the remote option was mostly just added for people using the data api. if you're using js, you might as well just call load yourself on your modal (that way you can listen for errors as well). thanks!

@fat fat closed this as completed Dec 21, 2012
@tghw
Copy link

tghw commented Dec 22, 2012

@fat Not including this simple callback increases the complexity of the Javascript that you need to write.

if you're using js, you might as well just call load yourself on your modal

That same argument can be made for show, shown, hide, and hidden.

With the load event, the code is straight forward:

$('#foo').bind('load', function() { /* do something cool */ });

But without a load event, it becomes a lot more complex.

  $('#do-modal').click(function(e) {
      e.stopPropagation();
      $('#foo .modal-body').load(this.href, function(response, status, xhr) {
          /* do something cool */
          $('#foo').modal();
      });
  });

The fact that I have to go digging for jQuery's .load() API belies the fact that this is less than optimal.

The change is simple, adds functionality that a number of people have asked for, and does so in a very straightforward way.

I hope you'll reconsider your decision.

@Nerian
Copy link
Author

Nerian commented Dec 27, 2012

I agree with Tyler. This will make enhancing Bootstrap much more easier and it just adds one line of code.

Please add this.

@cvn
Copy link

cvn commented Jan 17, 2013

I would like to see this as well.

@pixelcode
Copy link

Seconded, if remote is an option then I think a loaded event should be included as well

@stylenclass
Copy link

+1 on this, is there an easy way, @fat what's the best way to add the 'loaded' event outside of a minified bootstrap-min.js

@feens
Copy link

feens commented Feb 12, 2013

Add me to the list of those needing this functionality. It became especially apparent in IE (9) where code in the 'click' handler for the link being used to open the dialog was being after before the 'shown' callback as well.

@tghw
Copy link

tghw commented Feb 13, 2013

@feens Can you add a comment with your support on pull request #6846?

@hugochinchilla
Copy link

+1

this should be merged

@cvrebert
Copy link
Collaborator

cvrebert commented Mar 4, 2013

Quasi-duplicate of #4735.

@tafs7
Copy link

tafs7 commented Mar 26, 2013

+1 This is absolute crucial to make modals that load remote data work. I have an app that fetches HTML based on parameters passed to the controller action, and the response includes a form that relies on jquery validation. However, for validation to work, I have to wire up to the form after it has been added to the modal body. Without this fix, I have to manually call .load() as described above, and then open the modal once my form has been wired up. Very painful, when I could accomplish this with a data- attribute.

@jfortier-haptiq
Copy link

+1 here too! Actually found it very surprising that it wasn't there to begin with, seems only natural to me.

@Elyx0
Copy link

Elyx0 commented Apr 30, 2013

+1 Too. Please add it.

@cdekok
Copy link

cdekok commented May 3, 2013

+1 Was looking for the same thing :)

@cvrebert
Copy link
Collaborator

cvrebert commented May 3, 2013

Future +1s should probably be directed at #6846 instead.

@wimklerkx
Copy link

+1 This issue is potentially a show-stopper, now we're planning conversion from a custom developed front-end framework to Bootstrap

@Vinorcola
Copy link

+1 I would need this functionality too.

@cvrebert
Copy link
Collaborator

cvrebert commented Jul 7, 2013

@wimklerkx @Vinorcola I refer you both to #6846 (where someone has posted a workaround).

@Robdel12
Copy link

Robdel12 commented Jan 8, 2014

Yeah without this it makes using the remote option pretty useless. Unless you're just loading HTML/CSS, then it's okay.

@brycenesbitt
Copy link

+1 needed for google maps in a modal.

@cvrebert
Copy link
Collaborator

Locking this, since remote modals are deprecated per #14034.

@twbs twbs locked and limited conversation to collaborators Aug 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests