This is a migrated thread and some comments may be shown as answers.

Cannot bind the attribute to the input field as a object.

2 Answers 249 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Rasika
Top achievements
Rank 1
Rasika asked on 08 Sep 2015, 07:48 AM

I have a view model object . Here it is.

a{ b : {name : "p",id : "q", type : "text"} }

Here is my view.

<table data-template="myTemplate" data-bind="source: a"></table>

 <script type="text/x-kendo-template" id="leadFieldsTemplate">

    <tr>

          <td>

                  <input class="k-input k-textbox" data-bind=" attr: b  " />

          </td>

    </tr>

</script>​

But above method not working. 

Then I change it to like this

 <script type="text/x-kendo-template" id="leadFieldsTemplate">
    <tr>
          <td>
                  <input class="k-input k-textbox" data-bind=" attr: {name : b.name , id : b.id , type : b.type } " />
          </td>
    </tr>
</script>​​

Then it is working. So why the first method not working ???

In all time do I have to mentioned the attributes in the input field before bind them ??

 

Thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 11 Sep 2015, 07:55 AM
Hi Rasika,

There are a few things:
  1. The table's data-template points to "myTemplate", however the id of the provided template is "leadFieldsTemplate"
  2. Source binding expects an array, not an object
  3. Attr binding expects each attribute to be explicitly specified. Passing a field containing key/value pairs is not supported


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rasika
Top achievements
Rank 1
answered on 11 Sep 2015, 07:59 AM
Thank you very much for your help
Tags
NumericTextBox
Asked by
Rasika
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Rasika
Top achievements
Rank 1
Share this question
or