Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Implemented setOptions() function #357

Merged
merged 2 commits into from Aug 1, 2012
Merged

Conversation

raihan2006i
Copy link
Contributor

Store settings/options in element's data object so that we can change option for each element
So that we can change settings at anytime
Following example shows that we can change propertyToSearch and hintText at anytime we want
Example:


    $(document).ready(function() {
        $(element).tokenInput([{
                    "first_name": "John",
                    "last_name": "Doe",
                    "email": "john,doe@example.com",
                    "url": "https://si0.twimg.com/sticky/default_profile_images/
                },
                {
                    "first_name": "Adam",
                    "last_name": "Johnson",
                    "email": "adam.johnson@example.com",
                    "url": "https://si0.twimg.com/sticky/default_profile_images/
                }], {propertyToSearch: "first_name"}
        );
    });

Later we can do followings at anytime


$(element).tokenInput("setOptions", {propertyToSearch: 'first_name', hintText: "Type first name here to search"});
$(element).tokenInput("setOptions", {propertyToSearch: 'last_name', hintText: "Type last name here to search"});
$(element).tokenInput("setOptions", {propertyToSearch: 'email', hintText: "Type email here to search"});
$(element).tokenInput("setOptions", {propertyToSearch: 'url', hintText: "Type url here to search"});

Check Change propertyToSearch anytime demo in demo.html file

Store settings/options in element's data object so that we can change option for each element
So that we can change settings at anytime
Following example shows that we can change propertyToSearch and hintText at anytime we want
Example:
    $(document).ready(function() {
        $(element).tokenInput([{
                    "first_name": "Arthur",
                    "last_name": "Godfrey",
                    "email": "arthur_godfrey@nccu.edu",
                    "url": "https://si0.twimg.com/sticky/default_profile_images/
                },
                {
                    "first_name": "Adam",
                    "last_name": "Johnson",
                    "email": "wravo@yahoo.com",
                    "url": "https://si0.twimg.com/sticky/default_profile_images/
                }], {propertyToSearch: "first_name"}
        );
    });

Later we can do followings at anytime
$(element).tokenInput("setOptions", {propertyToSearch: 'first_name', hintText: "Type first name here to search"});
    $(element).tokenInput("setOptions", {propertyToSearch: 'last_name', hintText: "Type last name here to search"});
    $(element).tokenInput("setOptions", {propertyToSearch: 'email', hintText: "Type email here to search"});
    $(element).tokenInput("setOptions", {propertyToSearch: 'url', hintText: "Type url here to search"});

Check *Change propertyToSearch anytime* demo in demo.html file
@loopj
Copy link
Owner

loopj commented Jul 31, 2012

You've included people's (private?) email addresses in this pull request!

@loopj
Copy link
Owner

loopj commented Jul 31, 2012

Looks like I can no longer automatically merge.

This is an awesome pull request, could you re-sync with master to make it easier for me to test and merge this in? Thanks

Sync 'master' branch of https://github.com/loopj/jquery-tokeninput

Conflicts:
	demo.html
	src/jquery.tokeninput.js
@raihan2006i
Copy link
Contributor Author

Hello master branch is re-synced, please check and let me know if you face any problem. Thanks

loopj added a commit that referenced this pull request Aug 1, 2012
Implemented setOptions() function
@loopj loopj merged commit 39353a2 into loopj:master Aug 1, 2012
@loopj
Copy link
Owner

loopj commented Aug 1, 2012

Thanks @raihan2006i

@raihan2006i
Copy link
Contributor Author

You are welcome :) @loopj

@logaraja
Copy link

@raihan2006i how to change propertyToSearch, on Server-Backed Search

@raihan2006i
Copy link
Contributor Author

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