<!-- with: what_the_hell_can_be_used_here -->

34 views
Skip to first unread message

hipertracker

unread,
Mar 12, 2013, 11:23:31 AM3/12/13
to knock...@googlegroups.com
That lack of API is annoying. What argument can be passed to with: command? I cannot pass <!-- with: grouped.category_1 -->. Do I have to use only ugly <!-- ko with: grouped --><!-- ko with: category_1 --> ... grouped.category_1 is also a object, why I cannot use it? 

--
JZ

Michael Latta

unread,
Mar 12, 2013, 11:32:15 AM3/12/13
to knock...@googlegroups.com
In your first example you do not have the "ko" in the begining of the comment.  That would prevent it from working.  If you want to do with a sub item you need to use the following: <!-- ko with: grouped().category_1 -->

Michael

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Denys Khanzhiyev

unread,
Mar 12, 2013, 11:43:39 AM3/12/13
to knockoutjs
But that way if you have grouped()==null or undefined - you are in trouble.


2013/3/12 Michael Latta <mla...@technomage.com>

Michael Latta

unread,
Mar 12, 2013, 12:10:28 PM3/12/13
to knock...@googlegroups.com
Correct.  Knockout is not magic.  If grouped can be null then you need to have nested withs to account for that or use a computed observable that will account for it.

You could add a computed observable on the enclosing model like so:

self.grouped_category_1 = ko.computed(function() {
if (self.grouped() != null) {
return self.grouped().category_1();
}
return null;
}

(Coded off the top of my head so excuse any typeos)

Then you would only need one with binding.


Michael
Reply all
Reply to author
Forward
0 new messages