durandal knockout data-binding?

122 views
Skip to first unread message

Shaunt Kojabashian

unread,
May 6, 2013, 9:23:04 PM5/6/13
to duran...@googlegroups.com
Anyone else ever have issues where knockout doesn't seem to be doing a 2-way data-bind?
I've got a text field i'm making changes to and trying to capture the value after a button click and the new value doesn't seem to be changing...



I've dumbed this down but still seems like it's not doing what I want.

//summary.js
define(function (require) {
    var system = require('durandal/system');
    var app = require('durandal/app');
                    
    var self = this;    
    
    self.dueStart = ko.observable();
    self.dueEnd = ko.observable();    

    self.testData = function () {      
        system.log(self.dueStart());        
    };

    return {
        activate : function(context) {           
            self.dueStart('12/1/2012');
            return true;    
        }        
    };
});


//summary.html
<input id="dueStart" name="dueStart" type="text" data-bind="text : dueStart" /> 
<button data-bind="click: testData">Filter</button> 


if I change the contents of the textbox "dueStart" and click filter... the functoin runs, yet the system.log still returns 12/1/2012... data hasn't changed at all...
something seems screwy... any ideas?



James Barrow

unread,
May 7, 2013, 5:09:17 AM5/7/13
to duran...@googlegroups.com
Use the value binding and not the text binding, fell into this trap myself before :)

Rob Eisenberg

unread,
May 7, 2013, 8:29:45 AM5/7/13
to James Barrow, duran...@googlegroups.com
Good catch!


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



--
Rob Eisenberg,
President - Blue Spire
www.durandaljs.com

Shaunt Kojabashian

unread,
May 7, 2013, 11:41:42 AM5/7/13
to duran...@googlegroups.com, James Barrow, r...@bluespire.com
thank you .,.. saved me a lot of frustration right there :)
Reply all
Reply to author
Forward
0 new messages