Skip to content
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

Make 'params' as function that returns the object to build querystring as dynamic object. #38

Closed
itdev41k opened this issue Feb 1, 2013 · 8 comments

Comments

@itdev41k
Copy link

itdev41k commented Feb 1, 2013

No description provided.

@tkirda
Copy link
Member

tkirda commented Feb 3, 2013

You can use onSearchStart callback and set parameters before search starts.

@tkirda tkirda closed this as completed Feb 3, 2013
@Peter-Schmandra
Copy link

What is the syntax for resetting the parameters inside the onSearchStart callback? Thanks.

@Peter-Schmandra
Copy link

Found this code in another comment and works fine for updating params before search starts.

params:{whse_zone_key:function(){ return $('#whse_zone_key').val()}},

@itdev41k
Copy link
Author

itdev41k commented Feb 6, 2013

Thank you for your response. I'll use 'onSearchStart' callback to populate the 'params' object.

@Peter-Schmandra
Copy link

I would also prefer using the 'onSearchStart' callback but I cannot seem to get the syntax correct. Unfortunately there is no information in the documentation, examples or comments.

@tkirda
Copy link
Member

tkirda commented Feb 6, 2013

Try this:

$('.autocomplete').autocomplete({
    // ...
    onSearchStart: function (){
        $(this).autocomplete('setOptions', { params: { test: 'Value' } });
    }
});

@Peter-Schmandra
Copy link

Arg, I was so close! Yes that works, thanks so much. Also thanks for this for this fantastic JQuery plugin tkirda.

@angaziz
Copy link

angaziz commented Dec 17, 2013

I think what @tkirda say is changing the params when search is start, that's right but it will affect the parameter on The-Next time user trying to search (not on that time). Until this can be solved, maybe we can check this one :
http://stackoverflow.com/questions/10868537/ajax-autocomplete-for-jquery-how-to-send-dynamic-parameters

Hope help.

UPDATE :
If you are using two ID with one function call for two different params (like 'typeData'), maybe you can use this one :
$('#one, #two').autocomplete(option);
$('#one').autocomplete('setOptions', { params: { typeData: 'one' } });
$('#two').autocomplete('setOptions', { params: { typeData: 'two' } });

Thats it, maybe if you want set the params from Form Field you can use onchange from that field and set the option like the second or third line of the script above. @tkirda this plugin is awesome.

Have a nice day.

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

No branches or pull requests

4 participants