object generator (constructor) and WinJS.Binding.define -- how to use it (how to bind data) RRS feed

  • Question

  •   I've a constructor function like this:

      function emp(name, priority) {

        this.name = name;

      this.priority = name;


    var n = d1; //from form (UI)

    var m = d2; //from form

      var e1 = new emp(d1, d2);   //creates new object.

    If I want to bind this form UI to bindable object, I need to define it with WinJS.Binding.define. The object we pass to WinJS.Binding.define contains only property names, but no values. So how do I do create a constructor function with it?

      I want to create an observable object. Properties for that object will be updated by bindable template to UI, which sends user input to object.

    Friday, May 24, 2013 11:14 PM


  • Try this :

    var Employee = WinJS.Binding.define({        Name: "",        
    Priority : ""
    function empolyeeCntr(name,priority){
    return WinJS.Binding.as(new Employee ({ Name: name, Priority : priority});
    var e1 = employeeCntr(d1,d2);

    - Girija
    Tuesday, May 28, 2013 4:30 AM