Results 1 to 4 of 4

Thread: How to publish a config into parent component when the child has ViewModel

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    137

    Default How to publish a config into parent component when the child has ViewModel

    I have an extjs class which has a config field and now I want to publish its changes to the parent container.
    It is ok when I have no viewModel in child component but whenever I add a viewModel to the child class it breaks! and it is because of publishing. It publishes its data to the closest ViewModel!
    How can I achieve this?
    Check the fiddle : https://fiddle.sencha.com/#fiddle/hj2 for an example.
    in the fiddle if you uncomment the commented line , you will see that changing the field doesn't publish into the window header.

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi Mahmoud690--

    When you specify a viewmodel on the child component, configs will be published to the nearest hierarchical viewmodel, which in this case is that of the child component itself. There is currently a feature request open to allow this kind of behavior (EXTJS-15503).

    Thanks
    Joel

  3. #3
    Ext JS Premium Member
    Join Date
    Jun 2008
    Posts
    21
    Answers
    2

    Default

    Hi Joel,
    I didn't dig into the internals, but based on this fiddle, https://fiddle.sencha.com/#fiddle/hu5 it looks like it searches upward starting at the closest viewModel to find the data object to set. However, it currently stops once it has found the nearest matching data object and does not continue upward to the parent viewModels.

    So, it looks like parent viewModels do receive updates so long as the data object is not found below it in the viewModel hierarchy - you just need to make sure the name is different than any viewModel data objects below it.

    James

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

    Default

    Hi everyone. Check out the temporary solution here https://www.sencha.com/forum/showthr...ish-properties

Tags for this Thread

Posting Permissions

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