0

How to send persistant data backwards

Hi all,

I know that to send data from view 'A' to view 'B', we can set properties in loadview in view 'A' and those properties can used by this.persist in view 'B'.
But I have a situation where I have to send some data from view 'B' to view 'A' on the click of the back button. Is this possible?

Thanks in advance.

Priya

by
4 Replies
  • QUOTE (ganeshkumar @ Oct 28 2010, 05:48 PM) <{POST_SNAPBACK}>
    Hi all,

    I know that to send data from view 'A' to view 'B', we can set properties in loadview in view 'A' and those properties can used by this.persist in view 'B'.
    But I have a situation where I have to send some data from view 'B' to view 'A' on the click of the back button. Is this possible?

    Thanks in advance.

    Priya

    Priya,
    Data sent back to a previous view is accessible in the previous view via the backParams object off of the view. For example, view B:

    CODE
            createView: function() {
    this.controls.backButton = new KONtx.control.BackButton({
    label: 'Back to Main Menu',
    events: {
    onSelect: function () {
    KONtx.application.previousView({myVar: "test"});
    }
    }
    }).appendTo(this);


    and in view A:
    CODE
            updateView: function () {
    if (this.backParams.myVar) {
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    _dump(this.backParams);
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    }
    }


    Hope that helps.

    - Ben
    0
  • QUOTE (Benjamin Toll @ Oct 28 2010, 06:44 PM) <{POST_SNAPBACK}>
    Priya,
    Data sent back to a previous view is accessible in the previous view via the backParams object off of the view. For example, view B:

    CODE
            createView: function() {
    this.controls.backButton = new KONtx.control.BackButton({
    label: 'Back to Main Menu',
    events: {
    onSelect: function () {
    KONtx.application.previousView({myVar: "test"});
    }
    }
    }).appendTo(this);


    and in view A:
    CODE
            updateView: function () {
    if (this.backParams.myVar) {
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    _dump(this.backParams);
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    }
    }


    Hope that helps.

    - Ben



    Thanks Benjamin
    0
  • Hi,
    Is there any way I can access the data in the previous view, without using controls.backbutton, but by pressing the f10 button.

    Thanks
    Priya
    0
  • QUOTE (ganeshkumar @ Nov 8 2010, 12:46 AM) <{POST_SNAPBACK}>
    Hi,
    Is there any way I can access the data in the previous view, without using controls.backbutton, but by pressing the f10 button.

    Thanks
    Priya

    You could store it in the message center (KONtx.messages), or you could do it like this:

    CODE
            hideView: function () {
    this._listener.unsubscribeFrom(KONtx.application, "onActivateBackButton");
    },

    updateView: function() {
    this._listener.subscribeTo(KONtx.application, "onActivateBackButton");
    },

    _listener: function (event) {
    KONtx.application.previousView({foo: "bar"});
    event.preventDefault();
    }


    This would then be accessible in the previous view in this.backParams.

    - Ben
    0

Recent Posts

in Getting Started / Beginners - Yahoo! TV Widgets