tags:

views:

76

answers:

2

I'm using a Facebook-like autocomplete jquery library found at:

http://otisbean.com/dropbox/jquery.tokeninput.js

In my own html code, I have the following which works fine

<script type="text/javascript" language="javascript">

        $(document).ready(function() {
                $("#my_input_field").tokenInput("http://mysite.com/channel/1", {
                        classes: {
                                tokenList: "token-input-list-facebook",
                                inputToken: "token-input-input-token-facebook"
                        }
                });
        });

</script>

However, I want to create an html button that when clicked, will change http://mysite.com/channel/1 to http://mysite.com/channel/2.

So in my html button looks something like:

<input type="button" onclick="$('#my_input_field').url = 'http://mysite.com/channel/2'" />

That didn't work because .url property is not defined. I don't know how to find the relevant property of this object. How do I debug all this? Can anyone offer suggestions?

Thanks

A: 

Try storing your URL in a variable, and reference that variable instead. Then, at any point, you can update that variable to point to a different URL:

url = "http://mysite.com/channel/1";

$(document).ready(function() {
        $("#my_input_field").tokenInput(url, {
                classes: {
                        tokenList: "token-input-list-facebook",
                        inputToken: "token-input-input-token-facebook"
                }
        });
});

Then on your button, have this:

<input type="button" onClick="url='http://mysite.com/channel/2';" />
tambler
It appears the object received the value of url as opposed to the reference to the url variable. So even if I click the button, the object url property is still going to http://mysite.com/channel/1 . Is there a way for me to force it to pass by reference?
John
A: 

I gave up. I just hacked the original JS script and rewrote parts of it.

John