How to call internal functions of a plugin?
Hi there!
Firstoff: I know I ask about using a plugin, and I wasn't so sure where to put my question in, decided though the general jQuery-Forum would be better as my problem is more connected to jQuery than the plugin itself.
First off, I'm using this plugin and modified it myself a bit, adding new functions:
http://www.quasipartikel.at/multiselect/
You'll find the underlying .js for the component here:
http://www.quasipartikel.at/multiselect/js/ui.multiselect.js
Now, scroll to the end of the file, you'll find some "internal functions" like
_registerRemoveEvents
I defined such functions myself, for example something like this:
- _clearAvailableList: function() {
- var that = this;
- that.availableList.children('.ui-element').remove();
- that.element.find('option').remove();
- }
The call of this function works perfectly inside the .js file,
when I call it like this:
this._clearAvailableList();
What I want to do now is calling this function from the original html page,
with a button or so.
- <script type="text/javascript">
- function test()
- {
- //var mycomponent = $(".ui-multiselect");
- //mycomponent._clearAvailableList();
- _clearAvailableList();
- }
- </script>
-
- <input type="button" value="Click me!" onclick="test()" />
Unfortunately this doesnt work, and I dont know why.
I suppose, its because I just select the graphical represantion with .ui-multiselect,
but it's not the same as "this" in the internal .js-file.
mycomponent.hide() for example just works fine (of course).
How do I refer to "this" from the .js context / how can I call the internal functions from a component?
Thanks in Advance,
deadcode