<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Wijmo  &#187;  Topic: Suggestion for improved Knockout support</title> <atom:link href="http://wijmo.com/topic/suggestion-for-improved-knockout-support/feed/" rel="self" type="application/rss+xml" /><link>http://wijmo.com/topic/suggestion-for-improved-knockout-support/feed/</link> <description></description> <pubDate></pubDate> <generator>http://bbpress.org/?v=2.0.2</generator> <language>en</language> <item> <guid>http://wijmo.com/topic/suggestion-for-improved-knockout-support/#post-5099</guid><title><![CDATA[Suggestion for improved Knockout support]]></title><link>http://wijmo.com/topic/suggestion-for-improved-knockout-support/#post-5099</link> <pubDate>Mon, 28 May 2012 12:07:58 +0000</pubDate> <dc:creator>Mike.Griffin</dc:creator><description> <![CDATA[<p>Here&#8217;s a cool little helper routine I wrote for binding to wijmo controls that want a label and value.<br /> It works correctly if the data is observable or not observable.</p><pre class="brush: js">
var wijmo_binders = {};

wijmo_binders.getLabelValueBindings = function (collection, label, value) {

    var coll, idx, item, list = [];

    coll = ko.utils.unwrapObservable(collection);

    for (idx = 0; idx < coll.length; idx = idx + 1) {
        item = coll[idx];
        list.push({
            "label": ko.utils.unwrapObservable(item[label]),
            "value": ko.utils.unwrapObservable(item[value])
        });
    }

    return list;
};
</pre><p>I use it like this ..</p> </pre><pre class="brush: js">
list = wijmo_binders.getLabelValueBindings(coll, "Name", "TableId");
</pre><p>where "list" is bound as the data: to a combobox. I imagine I'll have more wijmo_binders which is why I created it that way.</p><p>Routines could be built into the controls like this, for instance.  (Notice the label/name tags ... in the data-bind)</p><pre class="brush: xml">
data-bind=wijlist: { listItems: list, label: 'Name', value: 'TableId', selectionMode: 'multiple' }">
</pre><p>Internally wijmo use the routine above to pull the label/name out of the collection (list) passed in, just a thought. It sure would make it easy for users to use wijmo/ko tegether, if they leave off the label/value bindings then the list alrleady has properties by those names.</p><p>Lovin me some wijmo + ko man, good work! I&#8217;m using it on a side project and my work is now going to use your controls since you added Knockout support, so quite a few purchases will be rolling in.</p> ]]> </description> </item> <item> <guid>http://wijmo.com/topic/suggestion-for-improved-knockout-support/#post-5102</guid><title><![CDATA[Reply To: Suggestion for improved Knockout support]]></title><link>http://wijmo.com/topic/suggestion-for-improved-knockout-support/#post-5102</link> <pubDate>Tue, 29 May 2012 01:14:38 +0000</pubDate> <dc:creator>mnmr</dc:creator><description> <![CDATA[<p>+1 from me! <img src='http://wijmo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]> </description> </item> </channel> </rss>
<!-- Served from: wijmo.com @ 2013-05-22 10:52:10 by W3 Total Cache -->