views:

31

answers:

1

I'm trying to alter the extraParams in this plugin based on a user action.

var t = new $.TextboxList('#entSearch', {unique: true, plugins: {
            autocomplete: {
                minLength: 3,
                queryRemote: true, 
                placeholder: false, 
                remote: {
                    url: "{{=URL(r=request, f='call/json/suggest')}}", 
                    extraParams: {type: "", guid: ""}
                    }
                }
            }
        });

Executing the following line throws an error: autocomplete.remote is undefined

var tmp = autocomplete['remote']['extraParams']['type'];

Is there a way to access these inner properties of the plugin like I would reference them in a dict?

+1  A: 

Define it as a variable so you can access it later.

var plugins = {
    autocomplete: {
        minLength: 3,
        queryRemote: true, 
        placeholder: false, 
        remote: {
            url: "{{=URL(r=request, f='call/json/suggest')}}", 
            extraParams: {type: "", guid: ""}
        }
    },
    t = new $.TextboxList('#entSearch', {unique: true, plugins: plugins});

Then you can access it as such:

var tmp = plugins.autocomplete.remote.extraParams.type;
// ... or ...
var tmp = plugins['autocomplete']['remote']['extraParams']['type'];
Matt Huggins
Thanks - I can access the values now and update them in 'plugins', but I can't set them in 't'. For some reason I cannot access 't' the same way: 't.plugins.autcomplete.remote.extraParams.type'. That's what I was attempting to do with 'autocomplete' above. Any idea why that would not work?
Wraith
It depends on how the TextboxList plugin is set up. Can't help you without knowing that. But they way you're trying to access the info definitely won't work.
Matt Huggins