开发者

use dojo connect to fire a function other than particular event listener

I have a function which rotates a slide show like startChangeImage(),My slideshow has to stop when there is a mouseover the slide show.

am tryin something like this

   dojo.connect(this.domNode,'onmouseover',this,this.stopChangeImage);
                    this.start = d开发者_如何学JAVAojo.connect(this.domNode,'onmouseout',this,this.startChangeImage);

.....

stopChangeImage:function () {
            dojo.disconnect(this.start);

        }


........

the thing is it starts rotating only after mouse out I want it to work at all times except mouseover.


This is happening because you are connecting the onmouseout event to startChangeImage(). If you want this slide show to start when the page loads, you could have an init() (or similar) function that gets called when the page loads to start the slide slow.

You also don't need the this. when using dojo.connect() with a context (see here). See the connect functions in the code sample below.

var pageClass = {

    stopChangeImage: function() { },

    startChangeImage: function() { },

    init: function() {

        this.startChangeImage();

        dojo.connect(this.domNode, 'onmouseover', this, 'stopChangeImage');
        this.start = dojo.connect(this.domNode, 'onmouseout', this, 'startChangeImage');
    }

};

dojo.addOnLoad(function() {

    pageClass.init();
});

The above code will start your slide slow when the page loads, but have it stop and start based on mouseover and mouseout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜