Search code examples
javascriptjqueryanimationbackbone.js

Use jQuery show() with complete function and no animation


This question is in addition to jQuery toggle() with no animation...

In order to avoid animation on show of element, I'm trying to replace below 2 lines

var that = this;
this.$el.show("fast", null, function(){that.updatePosition()});

with following,

this.$el.show();    
this.updatePosition();

Is it possible that function updatePosition will be called before current element becomes visible? If yes then what is the workaround solution i should try to avoid animation.


Solution

  • You can pass duration as 0 as a first argument in jQueryElement.show. The callback function will be invoked after 0 duration.

    $(this).show(0, function() {
      //callback function
    });