Change property of a Jquery object?
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 anyo开发者_如何学编程ne offer suggestions?
Thanks
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';" />
I gave up. I just hacked the original JS script and rewrote parts of it.
精彩评论