by Cabeza » Wed Sep 12, 2012 2:32 pm
Steve,
Needing to put together the functionality to show/hide a field depending of the value selected for another field and following your advice, I did the following:
1-created a javascripts.js file where I put
a- a function show_hide() which is essentially the same as the one you detail in your post, adapted to my environment
b- an anonymous function which calls show_hide(), i.e., ( function(){ show_hide() }) (); This to make use of the "autorun" property of anonymous functions so that the state of the field updates upon launch of the page.
2- widget:atts:onchange = "show_hide()" on the corresponding fields.ini to set a handle to trigger the toggle upon manually updating the field.
3- function block__custom_javascripts(){...} on ApplicationDelegate.php to add the reference to my javascripts.js to the Dataface Main Template.
First of all: it works. So thanks again.
But I sense that the implementation is kludgy (well, no surprise here me being the author). In particular I dislike the need for the function() and the anonymous function calling it to obtain a- autorefresh b-I would not know how to link the widget onchange to my show_hide() function.
Any other way to put this together?
Thanks in advance.