0

problem of destroy view

I have created two views like this

view A -> view B

and there is a back button in view B

when I press the back button I want to return to view A also destroy view B

Because there is some data changed in the view B, I must recreate a new view B

I have tried method destroyView and it doesn't work

Also I tried updateView, but the old view still existed, view B(old) and view B(new) appears together

Does anyone know how to solve the problem?

Thanks

Yinan

by
10 Replies
  • use the optional value in KONtx.application.loadView() to skip saving the view in the history stack.

    CODE
    KONtx.application.loadView('my-View',{datatosend},true);
    0
  • QUOTE (WidgetRealm @ Nov 15 2010, 09:44 AM) <{POST_SNAPBACK}>
    use the optional value in KONtx.application.loadView() to skip saving the view in the history stack.

    CODE
    KONtx.application.loadView('my-View',{datatosend},true);


    In fact , I don't want to save VIEW B, but I use back button in VIEW B

    Also, I tried to use loadview in VIEW B to load VIEW A, but it seems that it doesn't word
    0
  • I'm sincerely not understanding what you're doing, when you go from view b to view a all the data not saved are garbage collected. When you return to view b do you want to just change the data inside the elements? if it is so you should just update the data in the update view method. just remenber to not set them in create view but to leave them empty ( labels and such) if you want to change them dinamically.
    0
  • QUOTE (Gades @ Nov 16 2010, 01:47 AM) <{POST_SNAPBACK}>
    I'm sincerely not understanding what you're doing, when you go from view b to view a all the data not saved are garbage collected. When you return to view b do you want to just change the data inside the elements? if it is so you should just update the data in the update view method. just remenber to not set them in create view but to leave them empty ( labels and such) if you want to change them dinamically.


    View A is a login view, so when view B returns to view A is just like disconnect

    I also tried to use update view, but it seems that the old view B doesn't disappear

    For example this is a textbutton in view B
    CODEBOX
    var bottom1 = new KONtx.control.TextButton({
    label: $API.perfectUser.user_login,
    styles: {
    vOffset: text_button_header.outerHeight
    },
    textStyles: {
    color: '#FFFFFF',
    fontSize: KONtx.utility.scale(18),
    paddingLeft: KONtx.utility.scale(5),
    hAlign: 'center',
    vAlign: 'center'
    },
    events: {
    onSelect: function(event){
    var dialog = new KONtx.dialogs.Alert({
    title: "Email",
    message: $API.perfectUser.user_login,
    buttons: [{
    label: "back"
    }]
    });
    dialog.show();
    }
    }
    }).appendTo(this);



    $API.perfectUser.user_login is a variable global

    I returned to view A, and then, changed this variable, and again to view B

    and then, in the label, the data doesn't change, but in the alertBOX , it changed.

    I used update view, and the old variable and new variable appear together in the label
    0
  • If you set the label in the create view it will not change anymore like i already told previously, you must leave the label undefined and define it in the updateview
    0
  • QUOTE (Gades @ Nov 16 2010, 06:38 AM) <{POST_SNAPBACK}>
    If you set the label in the create view it will not change anymore

    This is not true, at all... :b
    CODE
    bottom1.setText("my new label");
    0
  • Also, scope your variable to the view int the create view
    CODE
    createView : function() {
    this.bottom1 = KONtx.controls.TextButton({label:"label 1"});
    },

    updateView : function() {
    this.bottom1.setText("label 2");
    }
    0
  • QUOTE (WidgetRealm @ Nov 16 2010, 07:34 PM) <{POST_SNAPBACK}>
    This is not true, at all... :band i was using setText ^^
    0
  • QUOTE (Gades @ Nov 16 2010, 06:38 AM) <{POST_SNAPBACK}>
    If you set the label in the create view it will not change anymore



    QUOTE (WidgetRealm @ Nov 16 2010, 07:38 PM) <{POST_SNAPBACK}>
    Also, scope your variable to the view int the create view
    CODE
    createView : function() {
    this.bottom1 = KONtx.controls.TextButton({label:"label 1"});
    },

    updateView : function() {
    this.bottom1.setText("label 2");
    }





    Anyway, thank you guys, the problem solved with second method

    a mistake i think: KONtx.control.TextButton not KONtx.controls.TextButton


    Another question, what's the difference between
    CODEBOX
    createView : function() {
    this.bottom1 = KONtx.controls.TextButton({label:"label 1"});
    },


    or
    CODEBOX
    createView : function() {
    this.controls.bottom1 = KONtx.controls.TextButton({label:"label 1"});
    },


    and

    CODEBOX
    createView : function() {
    var bottom1 = KONtx.controls.TextButton({label:"label 1"});
    },
    0
  • Nice catch on the "controls" versus "control" :DThis main issue here is that is creates a variable reference that is lost after the function runs. When you create a variable in a function it does not have any scope outside that function.
    0

Recent Posts

in General - Yahoo! TV Widgets