I love jQuery. I work with it quite a lot on various projects. One of the coolest features in my humble opinion is AutoComplete. There are a ton of different plugins you can work with, some are variations of others, but for the most part, they work pretty darn good out of the box.
I have been trying unsuccessfully over the past hour or so to pass in the value of a checkbox as a parameter to my AutoComplete plugin as follows:
1 2 3 4 5 | cacheLength:0, minChars:2, max:20, autoFill:false, extraParams: { active : $('input[name=status]').is(':checked') } |
Now the issue I was encountering was regardless of what the state of the checkbox was, checked or unchecked, the AutoComplete plugin always returned it’s initial value. So if by default it was unchecked, it always returned false. If by default it was checked, it always returned true.
After a bit of digging, I finally stumbled across this site that explains that the value is locked in once the AutoComplete plugin is initialized: http://stackoverflow.com/questions/1216222/jquery-passing-checkbox-values
So to solve the issue:
1 2 3 4 5 6 7 8 9 | cacheLength:0, minChars:2, max:20, autoFill:false, extraParams: { active : function() { return $('input[name=status]').is(':checked'); } } |
Awesome! Thanks to Stack Overflow and redsquare!
2 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion
You must be logged in to post a comment.