Correct way of binding a listener through markup?

4 posts, 0 answers
  1. TrentCioran
    TrentCioran avatar
    13 posts
    Member since:
    Aug 2012

    Posted 08 Mar 2012 Link to this post

    Hi,

    I have the next html

    <select name="month" data-role="dropdownlist" data-text-field="text" data-value-field="value" data-bind="source: months, value: selectedMonth, event: { change: changeListener }" required validationMessage="Please select {0}"></select>
    

    Unfortunatelly this doesn't take the listener, I also tried

    <select name="month" data-role="dropdownlist" data-text-field="text" data-value-field="value" data-bind="source: months, value: selectedMonth, change: changeListener" required validationMessage="Please select {0}"></select>
    with same results: no listener is triggered.


    Am I doing something wrong?

    Thanks in advance,
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 09 Mar 2012 Link to this post

    Hi,

     Currently the event binding does not work with Kendo Widgets. It works only with DOM elements. You can still wire the DropDownList change event like this:

    <select name="month" data-change="changeListener" ... >

    However the changeListener function should live in the global scope and not in the View-Model. Here is a live demo.

    Could you elaborate why you need to subscribe to the change event of the DropDownList? The value binding should eliminate this need.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. TrentCioran
    TrentCioran avatar
    13 posts
    Member since:
    Aug 2012

    Posted 09 Mar 2012 Link to this post

    Thanks for your reply Atanas, can you post the link? I think you forgot it =P.

    Answering your question, I have several dropdown lists grouped in couples to represent mont/year, given the selection of the first it gives the valid selections for the second and viceversa, that's why I need these listeners.

    Regards,
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Mar 2012 Link to this post

    Hi,

     Indeed I forgot the link. Here it is: http://jsbin.com/elesub/edit#javascript,html 

    We decided to add support for event binding via the data-bind attribute as well. "this" in the event handler will be the View-Model and the widget will be passed in the event arguments.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top