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
6 Answers, 1 is accepted
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
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
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
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
Hello Patric,
please let me know if you need further assistance with this approach.
Regards,
Petyo
Telerik
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/