Question

I'm creating a basic jQuery slideshow for my website using the Widget Factory.

$('#front-page-slideshow .slides-container').slideShow({});

Once the widget has been initiated, how can I get the selector that initiated it? Thanks.

$.widget('DDUI.slideShow', {

    options : {

        automatic:      true,   // Whether or not the slideShow is automatic
        speed:          '3000'  // The transition speed of the slides

    }, // options

    /**
     * Constructor
     */
    _create : function(){

        var caller = ???
        // 'caller' should be either string '#front-page-slideshow .slides-container'
        // or object '$('#front-page-slideshow .slides-container')'

    } // _create

});
Was it helpful?

Solution

A reference to a jQuery object containing the DOM element is available as a property of the instance as this.element.

As explained in the _create method documentation :

There are no parameters, but this.element and this.options are already set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top