GithubHelp home page GithubHelp logo

Events clashing about bootstrap-modal HOT 14 CLOSED

jschr avatar jschr commented on July 21, 2024
Events clashing

from bootstrap-modal.

Comments (14)

adam-lynch avatar adam-lynch commented on July 21, 2024

Also, I cannot change .trigger('hidden') to .trigger('hidden.modal') in bootstrap-modal.js:207; the backdrop is no longer removed. I cannot find anywhere where hidden is subscribed to and the backdrop is then removed.

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

If you namespace the events with event.namespace it will break everywhere that is just listening for the event. You will need to namespace all the listeners as well. The ModalManager class is where the show/hidden events are subscribed to.

I believe this line bootstrap-modalmanager.js:64 would have to be something like .on('show.modal.modalmanager') and the same goes for every other namespaced event.

I'm curious as I am also using the datepicker in my project and have had no issues, what event clashing are you experiencing?

Bootstrap will be namespacing all their events in an upcoming release so I plan to do the same when it is.

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

Ah, if you have other components inside the modal which fire hide/show events you will see your event subscriptions on the modal being fired for them as well. This is why I'm anxiously waiting for them to namespace events.

I put in a work around to make sure that the ModalManager class to make sure it would only fire the subscription if the modal was the one who fired it (see bootstrap-modalmanager.js:376). If I didn't do this, tabs within modals would cause the modalmanager to fire when you click a tab.

As for the focus issue, not sure if it's related or not but if you're able to create a jsfiddle demonstrating it I'd be glad to take a look.

from bootstrap-modal.

adam-lynch avatar adam-lynch commented on July 21, 2024

Ah ok.

#60; the issue my colleage has logged about the focus being lost in the modal.

from bootstrap-modal.

adam-lynch avatar adam-lynch commented on July 21, 2024

@jschr Shit, I accidentally deleted my comment between your last two. Have you still got it in your emails or anything?

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

Ah ok.

Well, I was working with the modal's hide event, cleaning up some stuff. At one stage I noticed some unexpected behaviour so I just stuck in an alert() to be fired whenver the event was triggered, and it was being triggered way too much. It almost seemed like it was on every click.

Side note: We did also have a focus problem in the modal though, where complete() seemed to be called on the first click of the modal, not when the transition ended (see bootstrap-modalmanager.js:96). Therefore, if you clicked a field for example, it would gain but then lose focus. I'll get my colleague to log an issue on it (and I'll link it here) because he was the one actually troubleshooting it. It could be related, but I did still had the problem when I namespaced all the events in bootstrap-datepicker and this project, minus show.

Cool, I can do it when I've time if you like since I want to contribute anyway, and it can be merged in when Bootstrap namespaces theirs.>

from bootstrap-modal.

adam-lynch avatar adam-lynch commented on July 21, 2024

I don't know how to properly link an existing pull request to an existing issue so here's the pull request related to this issue.

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

Closing for now as we now have a pull request but will wait for bootstrap to release their fix before merging.

from bootstrap-modal.

barmstrong avatar barmstrong commented on July 21, 2024

Is there a work around for this in the mean time? After adding bootstrap-modal we are no longer receiving shown events (probably others) on modals, so this sort of code no longer works:

$(document).on 'shown', '.modal', ()->
  $(this).find('.focus').focus()

I assume this is a related issue, but let me know if not. Thanks!

from bootstrap-modal.

barmstrong avatar barmstrong commented on July 21, 2024

Hmm, surprisingly...this works though:

$('.modal').on 'shown', ->
  $(this).find('.focus').focus()

It has different functionality, so we really want to use the previous version - any idea why the snippet in my previous comment would have stopped working but this one works? Thanks!

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

I think this is because I am using triggerHandler instead of trigger to fire the events. This is something that I need to change. It was a poor solution to solve some of the event namespacing issues that has been around since the first version. In the meantime you can make this change yourself in both the ModalManager and Modal classes to fix it. I will be pushing a fix for this as soon as I get some time.

from bootstrap-modal.

barmstrong avatar barmstrong commented on July 21, 2024

Thanks @jschr that worked perfectly actually (just did a global find/replace of triggerHandler to trigger). Seems like a pretty simple fix - shall I send a pull request?

from bootstrap-modal.

jschr avatar jschr commented on July 21, 2024

Ya sure that would be appreciated.

Thanks

from bootstrap-modal.

barmstrong avatar barmstrong commented on July 21, 2024

Done!
#69

On Fri, Feb 8, 2013 at 5:22 AM, Jordan Schroter [email protected]:

Ya sure that would be appreciated.

Thanks


Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-13289922.

from bootstrap-modal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.