-
Notifications
You must be signed in to change notification settings - Fork 598
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
Close button inside Sidr #21
Comments
I was able to implement a close button inside of div#sidr:
(Yes, I know |
Thank you rareyman, this helps me a lot! |
Awesome. I am glad I was able to help out. :) |
when closing, the sidr is closing very fast. Is there any way to delay it |
@rareyman This was exactly what I needed. Thank you very much. I used what you said in the form of an anchor inside the sidr menu itself.
@malleswarchinta there is an option to change the speed of the animation, though I haven't had much luck getting it to work. Example:
|
Sadly this way of closing the menu does not work for me, it doesn't respond. Doesn't give any errors either. Are there any other options? |
@vanillaweb make sure that the Div ID 'sidr' matches the '$.sidr('close', 'sidr');' in the onclick function :) This worked for me |
Hi, I tried to use the code it does not work for me, it doesn't respond. When i click the button, it has this error "Uncaught TypeError: Cannot read property 'sidr' of undefined onclick". Can you please help? Many thanks. |
dont know how to add the code. :( i tried to use the code from rareyman and LanceTurri. but no luck,it has this error "Uncaught TypeError: Cannot read property 'sidr' of undefined onclick". |
Bummer! It would be helpful if you can set up a test example on JsFiddle or show some source code so we can see what is going on. My guess is you don't have jQuery connected properly on your page or perhaps some other generic Javascript errors. Good luck! |
Rareyman, here is a sample HTML code, that did not work on my site as well: $(document).ready(function() { Any idea as of why would be highly appreciated |
HTML <div id="sidr"> <!-- this is the div holding the sidr; it has an ID of "sidr" -->
…
<a id="btnClose" href="#">Close</button> <!-- this is the close sidr button; it has an ID of "btnClose" -->
</div> Javascript $(document).ready(function() {
$('#btnClose').click(function(){ // when 'btnClose' is clicked…
$.sidr('close', 'sidr'); // close the div with the ID of "sidr"
});
}); |
@koteva I know it's late but for future readers, @rareyman wanted to add that if you want to implement close button
<div id="sidr"><ul>... YOUR MENU ...</ul><a id="closeButton">Close</a></div>
So the fastest solution I can imagine right now using only JS is to build div#sidr with close button inside, prepend cloned ul of your source menu and then initialize .sidr() without source property // build div#sidr with close button inside
var sidrDiv = $('<div id="sidr"><a id="closeButton">Close</a></div>');
// fill div#sidr with source menu, using jquery .clone() method
sidrDiv.prepend( $("#yourSourceMenu > ul").clone() );
// insert our div#sidr into DOM
$("body").prepend( sidrDiv );
// things under you would do anyway
// initialize sidr
$("#yourMenuOpeningButton").sidr({
name: "sidr" // same as our div ID
});
// and finally bind .sidr close functionality on our #closeButton click event
$("#closeButton").on("click", function() {
$.sidr("close", "sidr");
}); |
Did you notice, that if you try to put closing button inside Sidr id simply does not work, but works outside Sidr div. Any ideas or fixes?
The text was updated successfully, but these errors were encountered: