• Resolved James Revillini

    (@jrevillini)


    I just left a 5-star review because this plugin is AMAZING. Works really well with ASTRA

    My question is: how do I use pure JS to trigger a slider? I know how to code the JS and include it in my theme, but is there an API with functions like `$(‘#thesliderid’).offcanvassidebar(‘open’) \\jQuery
    document.getElementById(‘thesliderid’).offcanvassidebar(‘open’) \\vanilla JS`

    Thanks!

    Oh, and I noticed many support requests are procedural. Like they created a sidebar, filled it with widgets, but didn’t enable it or integrate with the theme correctly. I am going to try to create a video you could circulate and maybe pin as a top post.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter James Revillini

    (@jrevillini)

    Nevermind … I just found it here https://www.adchsm.com/slidebars/help/usage/opening-and-closing-slidebars/

    I think some examples in the main docs would be helpful. It was a little buried ??

    Thread Starter James Revillini

    (@jrevillini)

    OK looks like I do need some help. This was my attempt at a script that pops open a slidebar automatically. Can you help me troubleshoot? https://gist.github.com/jrevillini/a0d38709d8526ae197944a5200ab94d8

    Thread Starter James Revillini

    (@jrevillini)

    OK a couple JS tweaks worked. I do think this needs more documentation because when I tried to set up the window listener within the document.ready event, it failed. You can look at the various incarnations of the gist to see what I mean. I believe the second version is the one that shows the issue.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jrevillini,

    Sorry for my late reply and thank you for your review!
    I’m currently on holiday but will take a look at your gist asap!
    Any ideas to improve the documentation are very welcome.

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jrevillini

    Looking at your gist at the moment and I wouldn’t advice using it like this.

    In your gist you are creating a new instance of Slidebars so there are two active instances of slidebars active on your site. The one from this plugin and the one in your custom code.
    I’d advice to use the slidebars instance in this plugin like so:

    
    // don't run until main slidebars init has happened to avoid JS error
    jQuery( window ).on( 'ocs_after', function ( event, ocs ) {
    	// @TODO add cookie test
    	// @TODO add skip list
    	// @TODO add config based on body class or something
    	// the default
    
    	// The ocs variable is passed in the event as second parameter.
    	var s = ocs.slidebarsController;
    	//s.init(); //No need to reinitialize.
    
    	// Alternatively you can use the global ocsOffCanvasSidebars object. This is the same.
    	// Example:
    	// var s = ocsOffCanvasSidebars.slidebarsController;
    
    	s.open( 'ocs-fteaserslidebar' );
    } );
    

    Also see: https://github.com/JoryHogeveen/off-canvas-sidebars/wiki/JavaScript-API

    Hope this helps! Cheers, Jory

    • This reply was modified 5 years, 3 months ago by Jory Hogeveen.
    Thread Starter James Revillini

    (@jrevillini)

    hey @keraweb !
    sorry for late reply – also on holiday myself.
    thanks for the detailed reply. That explains a lot!
    best,
    Jimmy

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @jrevillini,

    No problem, if you encounter any issues when you are back, let me know!

    Also, if you like the plugin, please consider leaving a nice review, it will help the plugin grow ??

    Thanks, Jory

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘JS triggers’ is closed to new replies.