- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am using XDK 1995 with JQuery Mobile. I have a button on the header that closes and opens the sidebar. I also set the sidebar to be swipeable. I need to be able to tell whether the sidebar was swiped open or close because my sidebar toggle button changes depending on the state of the sidebar. Does anybody know if the sidebar generates an open or close event?
- Tags:
- HTML5
- Intel® XDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This thread is old. A sidebar event was added months ago.
Look into sidebar.js
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can controle the sidebar with this:
uib_sb.open_sidebar($sb)
uib_sb.close_sidebar($sb)
uib_sb.toggle_sidebar($sb)
uib_sb.close_all_sidebars()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Hamilton,
I am already using the commands to control the sidebar. What I need is how to find out if the sidebar was swiped closed or open. Is there an event I can add a listener for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Uhn... I never used this. I dont´t know. Sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no event yet. But that would be easy to add. The uib_sidebar.js file is put into your project and, as you can see, it's very straightforward. Make the change there to have it fire an event.
I'll add that event as a feature request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've just implemented something like this in my app, which I'm using to inject and remove a page overlay behind the sidebar when it opens.
Chris's comment above got the ball rolling for me, but there was still a great deal of trial-and-error trying to get it working properly. I can't imagine how many people have come across this page while searching for a way to do this, yet this thread has absolutely no useful information.. So in light of that, here's how I achieved this:
Inside the "www/sidebar/js/sidebar.js" file, in the "perform_open_close_sidebar()" function, I extended the "if (open) {}" check from the initial...
if (open) { should_toggle = !should_toggle; }
...to the following...
if (open) { should_toggle = !should_toggle; $(document).trigger('open_sidebar'); } else { $(document).trigger('close_sidebar'); }
This allows me to run custom functions anytime a sidebar is opened or closed, regardless of how it's triggered (by the "toggle", "open" or "close" functions, including activation by button or swipe).
Hope that helps someone. :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This thread is old. A sidebar event was added months ago.
Look into sidebar.js
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page