-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
Manually closing collapse #64
Comments
Thanks for spotting that out, I will look into it and provide a solution asap. |
Sorry for the delay, I just improved this, but it doesn't work properly in IE8, currently working on a fix. The problem is that it needs to know the target and the trigger inside the |
How so? The event is added through: this.btn.removeEventListener('click', this.toggle, false); Therefore, if I am getting this right (please, correct me if not), the trigger should always be |
Indeed you are wrong, the collapse instance does not know which one is |
It looks it does, really. When initializing each collapse, So, whileas it's true that I made a few tries with any collapse you have in the sapmple page (the menu one, the accordion and the one with two buttons), saving a pointer to the original button in a new field ( I even removed every reintialization of |
I have a new version of the file, un-minified only at this time. Would you like to test it in your app? The collapse |
I just downloaded the last version of collapse-native.js and repeated the two tests, getting the exact same results. |
Wait, I haven't committed yet. |
Ah, ok, I apologize. Anyways, there was no need to modify it for this purpose as, as I said, "self.btn" never changes. |
Also added a new feature for collapse to add 'open' class to the button's parent for further customization.
OK now, go ahead and download, test and let me know. |
It does not work managing it manually. As self.btn never seems to change, nor the target does. |
I was thinking the same while working on the code tonight, when I originally developed the script I was thinking of a solid solution for the use of accordions. I am going to try to change it now, and let you know. |
But it does work with accordion as well. You create a brand new instance of Collapse for each single button (even if the accordion is the exact same). |
You literally cycle throw all buttons (not collapsible items themselves) creating instances: var Collapses = document.querySelectorAll('[data-toggle="collapse"]'), i = 0, cll = Collapses.length;
for (i;i<cll;i++) {
var item = Collapses[i], options = {};
options.duration = item.getAttribute('data-duration');
new Collapse(item,options);
} |
The 'getTarget' method is needed in any case, we only know the btn as the element, we need to find out the target collapse. So there is a new commit, please download and try again. |
Yeah, yeah, of course. |
The new code doesn't change the btn and collapse on every |
Anyways, it is late here in Italy (01:10), so I am gonna quit thinking about JavaScript now, until tomorrow. See you soon and thank you very much for your work. If it helps you, I can modify the code myself, but not right now. Thank you again. See you tomorrow. |
Please test tomorrow the new code if you can do whatever you wanted in the first place. |
I sure will, thank you again. |
Ok, I just tested it and it seems to work well and nicely. Thank you very much again. |
Thanks for your input, I appreciate it. |
@thednp Can this be released soon? |
I believe so. |
Not sure what you mean. |
I mean do your own tests, maybe you find an issue with the current master, I hate deploying a new release and then right after a new stargazer finds a small little issue. |
😀 It seems that's how it goes. I'll do a little work on the latest master and report back. |
Well, I think you are too late, I am gonna release 1.0.3 in a few minutes. |
Ok now, you can play around with the latest release. |
@thednp |
I don't do that myself, I had a friend that did that, if you can contribute with that, I am happy. |
@thednp It's not hard. I assume you have NodeJS installed. Open the terminal and navigate to the bootstrap.native directory. (Make sure git is at the commit that you tagged as v1.0.3). Type If that throws an error, you will need to run I'm not familiar with bower, perhaps @IngwiePhoenix can help. |
I think I did it 💃 Please test. |
🎉 You did! |
My first ever deploy to the npm. |
Hi.
Is there any way to manually close a collapse created dynamically through:
There is a
.close(e)
method, but it requires an event parameter.Is there any way I can do it manually, asynchronously? It'd be really useful.
Thank you very much!
The text was updated successfully, but these errors were encountered: