Get element for binding

7 posts, 0 answers
  1. Rafa
    Rafa avatar
    13 posts
    Member since:
    Jan 2013

    Posted 09 Sep 2015 Link to this post

    Hi there

    When binding enabled/disabled or visible/invisible I normally use callback functions to check the current state. Unfortunately the element itself is not given to these callback functions.

    In my case, to determine the state of the element, I would need to check if the element, which called the callback function, is part of a disabled tab strip tab. But since there is no element given, I need to search for it in the DOM, which probably is not always reliable and could return multiple elements.

    So my Questions:
    Why is it, that no params are given to the callback function?
    Can I change that?

    Regards,
    Patric

  2. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 11 Sep 2015 Link to this post

    Hello Patric,

     

    the viewmodel functions are not "aware" of the elements bound to their results. Like you have noticed, there may be multiple elements bound to the same callbacks. 

     

    Can you post a sample of what you are trying to achieve? We may be able to suggest an alternative method for its implementation. 

     

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Rafa
    Rafa avatar
    13 posts
    Member since:
    Jan 2013

    Posted 16 Sep 2015 Link to this post

    Hello Petyo

    In the end I created multiple callback functions. But still, I came across this scenario quite a few times since I'm using kendo. Since the project I'm working on is to complex I tried to create a simpler example of what I mean over here: http://dojo.telerik.com/oFUte

    I can only guess, that one of the main reasons, why it's not intended to send the sender for the callback, that the callback is not observable aware unless I .get() a value from it inside the method itself.

    Regards,
    Patric

  5. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 18 Sep 2015 Link to this post

    Hello Patric,

    thank you for the clarification. What may help in that case would be the source binding approach. Please check this demo for what I mean.

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Rafa
    Rafa avatar
    13 posts
    Member since:
    Jan 2013

    Posted 21 Sep 2015 Link to this post

    Hello Petyo

    Thank you for your answer. I didn't know, that the dataSource item would be given to the method. This could be a solution, but only, if the dataSource would be updated on every change, to redraw the elements and recall the method.

    Regards,
    Patric

  7. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 23 Sep 2015 Link to this post

    Hello Patric,

     

    please let me know if you need further assistance with this approach. 

     

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. Joshua
    Joshua avatar
    66 posts
    Member since:
    May 2012

    Posted 14 Mar in reply to Petyo Link to this post

    I am trying to determine the element that is being bound as well. I am familiar with the datasource technique, but it still doesn't help me accomplish what i am trying to do. In this case I am building a wizard which is not well suited to being templatized. I have figured out how to hack around this and make a custom binding that sends in the element, but after 4 years of using kendo i think this is something that the framework would benefit from.

     

    I have an example of what i am trying to accomplish. I don't want to litter my model with showHide functions. http://jsfiddle.net/grippstick/jodq7zug/

Back to Top
Kendo UI is VS 2017 Ready