Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

every widget should self-identify (feature request) #5729

Closed
didiergm opened this issue Mar 4, 2013 · 1 comment
Closed

every widget should self-identify (feature request) #5729

didiergm opened this issue Mar 4, 2013 · 1 comment

Comments

@didiergm
Copy link

didiergm commented Mar 4, 2013

Problem: there is no unique way to tell what a widget is from a js routine.

Context: when writing generic modules to, for example reset each widget to a default value writing a generic routine is fairly difficult and not consistent as each widget has a different way of being changed and refreshed on screen. (this could also streamline form validations, reset, display of data etc ...)

for example refreshing a select element is different whether the widget is a slider or a select menu.
// exerpt form a form display refresh routine
....
// this is weird for a flip-switch
$('select.ui-slider-switch', pageid).slider('refresh');
// this is for a 'normal' select
$('select', pageid).not('.ui-slider-switch').selectmenu('refresh');
...

checking for .ui-slider-switch is too close to jqm and may fail in a future release if some css changes.

So I suggest to populate a new "data-widget-is" value indicating which widget has been created when jqm enhances the markup. in my example "widget-is" would be equal to either flipswitch or selectmenu, or maybe expand the use of data-role

benefit: this would make interacting with jqm widgets easier, more consistent and less reliant on some specific markup, subject to change in a future release.

@jaspermdegroot
Copy link
Contributor

@didiergm

I am closing this as a feature request. However, I wonder what would be the difference between the data- attribute that you suggest and data-role. You can also set an ID for the native element and use it as selector.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants