Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1369 in a recent build.
  1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    14
    Vote Rating
    0
    michal.smolinski is on a distinguished road

      0  

    Default Ext.Viewport.down() returns outdated components

    Ext.Viewport.down() returns outdated components


    Dear all,

    I've encountered strange problem in the PR3 (in PR2 it worked OK): I use Ext.Viewport.down() to get the reference to a view item (in this case it is textfield). The problem appears when I enter some text to this textfield and then invoke Ext.Viewport.down() to get the reference to it. The reference seems to address the proper component (the id is OK - the same as the id of the component in DOM), however value returned by getValue() is wrong - instead of the new value entered to the textfield, I get the initial value set during textfield construction.

    Have any of you encountered such a problem with PR3?

    Thanks,
    Michal

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,633
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I do not see this behavior in PR3:

    Code:
    Ext.create('Ext.form.Panel', {
        fullscreen : true,
        items      : [
            {
                xtype : 'textfield',
                label : 'Text'
            },
            {
                xtype   : 'button',
                text    : 'Get Value',
                handler : function() {
                    var text  = Ext.Viewport.down('textfield'),
                        value = text.getValue();
    
                    console.log(value);
                }
            }
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    14
    Vote Rating
    0
    michal.smolinski is on a distinguished road

      0  

    Default


    OK, I found out what is going on. The problem is that when you instantiate the component like this:

    Code:
    Ext.create('Ext.field.Text', { value: 'Some initial value'});
    then you will be always receiving the initial value when calling getValue(), no matter what is actually entered to the text box. To workaround this, I use

    Code:
    var temp = Ext.create('Ext.field.Text', {});
    temp.setValue('Some initial value');
    and now the getValue() method returns the proper value. So the problem in fact is connected with the bug in the text field implementation, not the Viewport.down() method.

    Somebody has posted similar issue here: http://www.sencha.com/forum/showthread.php?161822-PR3-Numberfields-with-a-value-attribute-config-always-return-their-initial-value

    Michal

  4. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Quote Originally Posted by michal.smolinski View Post
    Dear all,

    I've encountered strange problem in the PR3 (in PR2 it worked OK): I use Ext.Viewport.down() to get the reference to a view item (in this case it is textfield). The problem appears when I enter some text to this textfield and then invoke Ext.Viewport.down() to get the reference to it. The reference seems to address the proper component (the id is OK - the same as the id of the component in DOM), however value returned by getValue() is wrong - instead of the new value entered to the textfield, I get the initial value set during textfield construction.

    Have any of you encountered such a problem with PR3?

    Thanks,
    Michal
    Hi Michal.
    Do you destroy your viewport items in some point of your application and then you create them again?
    I'm asking you because I had (currently having and already reported) the same issue with the form components.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  5. #5
    Sencha User
    Join Date
    Jul 2009
    Posts
    14
    Vote Rating
    0
    michal.smolinski is on a distinguished road

      0  

    Default


    At the beginning I was destroying the whole views as soon as they became hidden but this resulted in similarly looking problem but of different nature: At that time I've been using refs: mechanism of the controller to get references to my view items but soon discovered that the ref seems to be fixed to the first instance of the view item ever created. When I destroyed the view and then recreated it when it again became visible, the ref was still returning the reference to the old view item, which resulted in wrong values being read from textfields. This is why I switched to the Ext.Viewport.down() method. Later I abandoned the concept of destroying views when they're hidden but haven't changed the code for accessing view items. And this is why I initially thought that the problem in the title of this thread is related to the Ext.Viewport.down() functionality.

    Michal

  6. #6
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Quote Originally Posted by michal.smolinski View Post
    At the beginning I was destroying the whole views as soon as they became hidden but this resulted in similarly looking problem but of different nature: At that time I've been using refs: mechanism of the controller to get references to my view items but soon discovered that the ref seems to be fixed to the first instance of the view item ever created. When I destroyed the view and then recreated it when it again became visible, the ref was still returning the reference to the old view item, which resulted in wrong values being read from textfields.
    Yeah actually this is a know problem related to form components and the dev team is working to solve it.

    So, if I understand what is your situation now, you create new views without destroy them right?
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  7. #7
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    I made some test and actually it seems to be a bug.
    So I'm moving this thread to the Sencha Touch 2 Bugs forum.

    Just to let you know, until this bug is fixed, you can get the textfield value as follows:

    Code:
    var txt = Ext.create('Ext.field.Text', { value: 'Some initial value'});
    txt.getComponent().getValue();
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  8. #8
    Sencha User
    Join Date
    Jul 2009
    Posts
    14
    Vote Rating
    0
    michal.smolinski is on a distinguished road

      0  

    Default


    I currently use hybrid approach: I don't destroy and recreate views but every time I show them I call my custom reinitialize() function (invoked from show handler). This way I can preserve some view items which are always the same (like navigation buttons, toolbars etc.) and I'm replacing only the view items I really need to be replaced (for example, I have a common view for displaying contact data - sometimes the contact contains only name and surname, sometimes it contains a few phone numbers, emails, addresses and so on). And of course original initialize() invokes at the end reinitialize(). This is a pretty ugly approach but at least it works

    Many thanks for taking your time to analyze this issue and confirming it as a bug. Now I'm sure it will get fixed soon

    And thanks for the workaround: it looks less workaroundish than my solution - which is not to use the initial value: config at all...

    Michal

  9. #9
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    21
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    This issue has been fixed for the next release.

    Sencha Inc

    Jamie Avins

    @jamieavins