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

Provide a user friendly method to set global options #1880

Closed
gseguin opened this issue Jun 21, 2011 · 9 comments
Closed

Provide a user friendly method to set global options #1880

gseguin opened this issue Jun 21, 2011 · 9 comments

Comments

@gseguin
Copy link
Contributor

gseguin commented Jun 21, 2011

Today to enable the back button globally we have to type $.mobile.page.prototype.options.addBackBtn = true. It would be more user-friendly to have some utility method like $.mobile.option(optionName, newValue) to wrap that call.

@eddiemonge
Copy link
Contributor

Or that can be passed a key value set of options.

@gseguin
Copy link
Contributor Author

gseguin commented Jun 21, 2011

Sure! So 4 signatures:
$.mobile.option(optionName) returns the option value
$.mobile.option([optionName_1,optionName_2, ...]) returns an array of option values
$.mobile.option(optionName, newValue) sets the option to newValue
$.mobile.option([optionName_1, optionName_2, ...], [newValue_1, newValue_2, ...]) sets options to the respective values

@scottjehl
Copy link

Nice!
I could see this working well if the first argument was the plugin name ("page" in this case). that way it would be properly targeted to the correct plugin, and not global config.

@gseguin
Copy link
Contributor Author

gseguin commented Jun 22, 2011

$.mobile.option( plugin, optionName ) returns the option value
$.mobile.option( plugin, [optionName_1,optionName_2, ...] ) returns an array of option values
$.mobile.option( plugin, optionName, newValue ) sets the option to newValue
$.mobile.option( plugin, [optionName_1, optionName_2, ...], [newValue_1, newValue_2, ...] ) sets options to the respective values

@scottjehl
Copy link

+1

@eddiemonge
Copy link
Contributor

$.mobile.option( plugin, optionName ) returns the option value
$.mobile.option( plugin, [optionName_1,optionName_2, ...] ) returns an array of option values
$.mobile.option( plugin, optionName, newValue ) sets the option to newValue
$.mobile.option( {pluginName_2: { optionName_1: newValue_1, optionName_2: newValue_2}, {pluginName_2: { optionName_1: newValue_1, optionName_2: newValue_2}}   ) sets options to the respective values

@scottjehl
Copy link

One thought: in the interest of keeping things concise until we really need to add more, would be it worth considering just one method for setting a widget option? That would address the concern above without adding a lot of code...

$.mobile.setWidgetOption( plugin, optionName, value  ) sets the option to newValue

@gseguin
Copy link
Contributor Author

gseguin commented Jun 22, 2011

And keeping $.mobile.option( plugin, optionName ) for read access, right?
I think that makes sense, I don't think the batch version would be used that often anyway, would it?

@ghost ghost assigned gseguin Jul 7, 2011
@toddparker
Copy link
Contributor

Added to the feature request wiki:
https://github.com/jquery/jquery-mobile/wiki/Feature-Requests

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

4 participants