0

Executing Method when page load 2nd Time

Hi, I have a situation now where I need a method to execute instantly when the view is loaded for the second time without a need for controls to trigger it. Is there anyway i can do that?

Thanks in advance.

by
1 Reply
  • QUOTE (Wei loon Ang @ Apr 10 2011, 02:13 AM) <{POST_SNAPBACK}>
    Hi, I have a situation now where I need a method to execute instantly when the view is loaded for the second time without a need for controls to trigger it. Is there anyway i can do that?

    Thanks in advance.

    You'll need to track the state internally.

    There are many ways to do this. Here's one:
    CODE
            _counter: 0,

    _myMessage: function () {
    log("################################################");
    log("this is the second time the view has been loaded");
    log("################################################");
    },

    updateView: function () {;
    if (++this._counter === 2) {
    this._myMessage();
    }
    }

    Here's another:
    CODE
            _myMessage: function () {
    log("################################################");
    log("this is the second time the view has been loaded");
    log("################################################");
    },

    updateView: function () {
    if (!this._myMessage.counter) {
    this._myMessage.counter = 0;
    }
    if (++this._myMessage.counter === 2) {
    this._myMessage();
    }
    }
    0

Recent Posts

in General - Yahoo! TV Widgets