I've built myself a custom plugin that works nicely, but I have one
(maybe two) little sticking points....
My plugin takes the form like this:
(function ($) {
$.fn.myPlugin = function (options) {
return this.each( function () {
$(this).data("myValue", "some_value");
});
function show() {
alert($(this).data("myValue"));
}
};
$.fn.myPlugin.getValue = function () {
return $(this).data("myValue");
}
})(jQuery);
I want to the implementing user to be able to ask for the specific value
with something like $("#myObj").getValue(); - or even
$("#myObj").myPlugin.getValue(); The getValue() method shown above is
not working - the "this" object is wrong. So, I'm looking for ways to
accomplish this.
Second, I want to be able to explitly set the value via
$("#myObj").setValue("new_value");
This set method would need to change the value stored via the .data()
function, AND call an internal method to display the new value (such as
the show() method shown above)...
I'm drawing blanks and dead ends in my efforts on these two points. Any
suggestions? (other than calling the .data() function directly - I may
be changing the storage method....)
Thanks in advance.
Shawn