generic $(...).val() wrapper for ui widgets ? Introspection ?
Hi,
Most UI widget I consider using and implementing in my apps intend to provide a nicer way to represent form elements (compared to native HTML). Hence, they represent a _value_ using various visual elements (ex: color picker for rgb values).
The val() method won't work on widgets though. This makes generic coding much harder because I have to know how is implemented a given form value under the hood (i.e. know which widget has been loaded to replace the native form element, and figure out how to interact with this widget to set/get value)
Is there a way I could create a generic method that would work both on widgets and native form elements ?
Here is what I have in mind:
$("#formvalue").someWidget({ ... });
$("#formvalue").genericVal("A value");
var value=$('#formvalue').genericVal()
Is there some introspection capabilities in the widget factory I have missed ? (know which widget implements a given DOM element ; know if it as a given method, property, option ? Obtain the list of options for a given widget ?)
Thanks in advance for any hint..