Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Workaround: Child component's ViewModel breaks it's publish properties

  1. #11
    Sencha Premium Member Trevor4001's Avatar
    Join Date
    Sep 2013
    Posts
    113
    Answers
    2

    Default

    Thanks for the workaround, Alexey. An alternative that avoids private code is to define the following on the component class. Note, this will not work when defined on a mixin.

    Code:
    // True if the component is publishing state
    publishingState: false,
    
    
    lookupViewModel: function(skipThis) {
       if (this.publishingState) {
          return this.callParent([true]);
       }
    
    
       return this.callParent(arguments);
    },
    
    
    publishState: function(property, value) {
       this.publishingState = true;
       this.callParent(arguments);
       this.publishingState = false;
    }
    Trevor Karjanis

  2. #12
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53
    Answers
    2

    Default

    Hi Trevor, thanks for sharing!

  3. #13
    Sencha User
    Join Date
    Oct 2009
    Posts
    30
    Answers
    1

    Default

    For this to work in ExtJs 7 - modern toolkit
    I had to make this change:

    Code:
    publishInitialState: function () {
        var me = this,
            state = me.publishedState || (me.publishedState = {}),
            publishes = me.getPublishes(),
            // Ext 7 prefixes config properties with a "_"
            propPrefix = Ext.getVersion().isGreaterThanOrEqual(7) ? '_' : '',
            name;
    
    
    
    
        for (name in publishes) {
            if (state[name] === undefined) {
                me.publishState(name, me[propPrefix + name]);
            }
        }
    }

  4. #14
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53
    Answers
    2

    Thumbs up

    That's awesome! Thank you for sharing your workaround! Feel free to create a PR https://github.com/alexeysolonets/extjs-mvvm-extensions

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 4
    Last Post: 28 Apr 2015, 10:20 AM
  2. Replies: 3
    Last Post: 28 Apr 2015, 10:18 AM
  3. Replies: 2
    Last Post: 3 Sep 2014, 5:40 AM
  4. Forcing parent ViewModel data to be available to child
    By estesbubba in forum Ext 5: Q&A
    Replies: 1
    Last Post: 14 Aug 2014, 4:25 AM
  5. How to listen ViewModel properties changes?
    By nikolay.bobrovskiy in forum Ext 5: Q&A
    Replies: 2
    Last Post: 19 Jun 2014, 3:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •