Skip to content

Flip switches do not have label when using ng-options #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rodcloutier opened this issue Feb 19, 2013 · 8 comments
Closed

Flip switches do not have label when using ng-options #127

rodcloutier opened this issue Feb 19, 2013 · 8 comments

Comments

@rodcloutier
Copy link

When using the ng-options in a select form element that uses the data-role="slider", the labels are not displayed

See fiddle http://jsfiddle.net/sMksx/2/

@tbosch
Copy link
Contributor

tbosch commented Feb 21, 2013

Thanks for reporting!

rodcloutier added a commit to rodcloutier/jquery-mobile-angular-adapter that referenced this issue Feb 26, 2013
@tbosch
Copy link
Contributor

tbosch commented Mar 1, 2013

Hi,
thanks for your pull request!
However, I think this solution is not the whole thing. If someone changes the values of ng-options after the slider was created, we cannot react to it as the refresh function of slider does not re-read the options. The right thing to do would be to detect changes to children (via the $childrenChanged event of the adapter) and recreate the widget in that case...
In total, this is a bug in jquery mobile, as the refresh function of the slider widget should be able to adjust to changed options...

Tobias

@rodcloutier
Copy link
Author

But in the meantime, wouldn't it be better to at least display the label. It would make flip switch that do not change the value of ng-options. As it stands, we cannot use flip switches at all.

@tbosch
Copy link
Contributor

tbosch commented Mar 1, 2013

Hi,
mmh... You can use flip switches with <option> entries... However, I haven't checked if it's possible to use ng-repeat on the options...

@rodcloutier
Copy link
Author

Angular strongly suggest using ng-options and avoid using ng-repeat on the options. See the following Angularjs issue angular/angular.js#639

I also updated a fiddle to show that none of the option work
http://jsfiddle.net/rodcloutier/sMksx/6/

@tbosch
Copy link
Contributor

tbosch commented Mar 4, 2013

Hi,
thanks for checking on the details of ng-options!
With the last commit, all of your examples are working: http://jsfiddle.net/sMksx/7/

I implemented it as discussed: The slider will take the initial values of ng-options and ng-repeat. Changing the options afterwards does not change the slider though.

Thanks for reporting and your pull request! Hope it will be easier next time now that we have testacular and travis-ci...

Tobias

@tbosch tbosch closed this as completed Mar 4, 2013
@rodcloutier
Copy link
Author

Unless I am misunderstanding how to use ngm-shared-controller but flip switches are not working when using a shared controller.

See fiddle http://jsfiddle.net/rodcloutier/sMksx/8/

@tbosch
Copy link
Contributor

tbosch commented Mar 15, 2013

Hi,
if you are using shared controllers, you have to give your controller a prefix, e.g. ngm-shared-controller="main:MainController" instead of ngm-shared-controller="MainController". And then use this prefix in your page, e.g. main.options. Your jsfiddle shows a console error from ngm-shared-controller that complains about this missing prefix.
Here is a corrected version: http://jsfiddle.net/sMksx/9/

Tobias

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

Successfully merging a pull request may close this issue.

2 participants