Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was 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

Description

@gseguin
Contributor

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.

Activity

eddiemonge

eddiemonge commented on Jun 21, 2011

@eddiemonge
Contributor

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

gseguin

gseguin commented on Jun 21, 2011

@gseguin
ContributorAuthor

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

scottjehl commented on Jun 22, 2011

@scottjehl

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

gseguin commented on Jun 22, 2011

@gseguin
ContributorAuthor

$.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

scottjehl commented on Jun 22, 2011

@scottjehl

+1

eddiemonge

eddiemonge commented on Jun 22, 2011

@eddiemonge
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

scottjehl commented on Jun 22, 2011

@scottjehl

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

gseguin commented on Jun 22, 2011

@gseguin
ContributorAuthor

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 assigned on Jul 7, 2011
toddparker

toddparker commented on Sep 27, 2011

@toddparker
Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @eddiemonge@scottjehl@toddparker@gseguin

        Issue actions

          Provide a user friendly method to set global options · Issue #1880 · jquery-archive/jquery-mobile