Open sunilw opened 8 years ago
+1
It's better to have some sort of API, at least, open()
and close()
.
Please.
It is fairly easy to do it. I've created a branch (my repo has diverged extensively from this one) feature/open-api where I implemented this for the sake of this issue.
Please help yourselves to try it out and let me know how it works.
Note that feature/open-api branch diverges from my own master as well :joy:
Have fun
Hey @adnasa thanks for forking this script and adding some open/close API functionality. Only thing is, and excuse my JS / jQuery noobness, but I'm trying to use the API like so:
$(document).keyup(function(ev){
if(ev.keyCode == 27) {
$.animatedModal.close();
}
});
But I receive a TypeError: $.animatedModal is undefined
error message. Any chance you can point me in the right direction?
@onetrev ooooh, it's been a while since I wrote this but after a quick read on the code, this should work
var demo = $("#demo01").animatedModal();
demo.open()
demo.close()
Good news, that was helpful for me to get the script to fire.... Bad news... There are errors now within your edited script. :(
animatedModal.min.js:107 Uncaught TypeError: Cannot read property 'preventDefault' of undefinedcloseModal @ animatedModal.min.js:107
(anonymous function) @ demos.html:61
m.event.dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
@onetrev :) my bad
as you can see, there are two event.preventDefault()
called in this file on Line 107 and Line 88...
Just remove those and you should be fine
Radical, thanks!!! I can now let you know your script works perfectly! Hopefully you get a chance to adjust it in your fork in case anyone comes along and needs it.
Sure would be nice if this could be added to the original animatedModal.js repo, but not sure if it's still active. Doesn't look like it.
@adnasa thanks for api! is working ;)
@onetrev code is updated Should work better now ;)
enjoy
Awesome thanks @adnasa! It worked with the edits you suggested previously, but I dropped the updated version and it continues to work nicely. Thanks again!
@adnasa: It's great having an open method. However, when I use that method, the z-index set inline on the modal div remains at -9999. So the div remains invisible.
@sunilw okay... here is a (couple of) thoughts
animatedModal
. Let's move the discussion there if this is still pressing, and that we keep the discussion relevant to a solution (which is in my repo)I highly suggest that we open a PR in this repo to provide a complete solution to the original lib so we no longer have to jump between repos
Someone has a solution for this? if i do
var mymodal =$("#animatedModal").animatedModal();
mymodal.open();
or If i try to close it, all the time I get demos.html:55 Uncaught TypeError: Cannot read property 'open' of undefined
the #animatedModal
is the Id of the div that I would like to have as modal.
If you want to be able to do this @esseti you have to use the fork that @joaopereirawd created. And there are details here for how to use it: https://github.com/joaopereirawd/animatedModal.js/issues/24
@adnasa has fork that provides a way to open the modal from js.
I'd love to see the ability to close the modal programmatically as well. This would allow a 'close' event to be invoked in a sequence of events with greater ease.