Binding to multiple view models nested in the Dom.

3 posts, 1 answers
  1. James
    James avatar
    7 posts
    Member since:
    Jun 2012

    Posted 22 Feb 2013 Link to this post


    I am trying to bind a model to a higherlevel element and then later bind another model to something nested deeper in the dom.

    When I do this, i get the following stack trace:
    1. Uncaught TypeError: Cannot read property 'parent' of undefined kendo.all.js:8419
      1. binders.source.Binder.extend.renderkendo.all.js:8419
      2. binders.source.Binder.extend.refreshkendo.all.js:8332
      3. Class.extend.bindkendo.all.js:8158
      4. Class.extend.applyBindingkendo.all.js:8954
      5. Class.extend.bindkendo.all.js:8930
      6. window.CubeBrowserModelBinder.CubeBrowserModelBinder.bindcubebrowser.model.binder.js:15
      7. CubeBrowserModelBindercubebrowser.model.binder.js:7
      8. (anonymous function)59:478
      9. jQuery.Callbacks.firejquery-1.8.3.js:974
      10. jQuery.Callbacks.self.fireWithjquery-1.8.3.js:1084
      11. jQuery.extend.readyjquery-1.8.3.js:406
      12. DOMContentLoaded

    Which looks to be caused by my 2nd view using data-bind to source and then  a template

    I have tried to replicate it here: and that gives me a different error but i believe it is close to the same problem.
    1. Uncaught TypeError: Cannot call method 'replace' of undefined kendo.all.min.js:9
      1. Template.compilekendo.all.min.js:9
      2. p.isFunction.fjquery-1.8.2.min.js:2
      3. parseOptionskendo.all.min.js:9
      4. (anonymous function)edit:21
      5. f

    I noticed this one: but i dont think i can see a way to get a jquery selector to correctly exclude the deeper elements.

    But beyond that I would not expect the code to throw an error.

    Appreciate your help on this



  2. Answer
    Daniel avatar
    2231 posts

    Posted 25 Feb 2013 Link to this post

    Hello James,

    The error in the jsBin is thrown because the templates are not yet initialized when binding the viewModel. You should bind the viewModel in the document ready event or move the script after the templates in order to avoid it.
    Regarding the error with the binding - it occurs because the source binding always requires initial value. The deeper elements only cannot be excluded and you should either exclude "cubebrowserpanes" from the binding or add the "gridPane" content(or attributes) dynamically after the main viewModel is bound. I update the sample to show one possible approach.

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. James
    James avatar
    7 posts
    Member since:
    Jun 2012

    Posted 01 Mar 2013 Link to this post

    Thanks for the response Daniel, doing the trick of putting the whole 2nd view into a template did the trick for me.
Back to Top