About getting the method's properties in treetable
Hi:
I try to enclose treetable into my library, but there comes a problem about how to
invoke each function in treetable individually.
The main code snippet is as following:
- $.fn.treetable = function(method) {
- if (methods[method]) {
- return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
- } else if (typeof method === 'object' || !method) {
- return methods.init.apply(this, arguments);
- } else {
- return $.error("Method " + method + " does not exist on jQuery.treetable");
- }
- };
And the main problems is it using methods[method] to map the options to individual function,
but if I hope to use its all function in my library via the same way, it will be duplicated and
verbose. Something like that:
- $.fn.myownfunction=function(options)
- {
- this.treetable(options)
- }
Seems useful, but It means I can not add my own options in initial step. Otherwise, I need to do the same things like
- $.fn.myownfunction=function(method)
- {
- if (methods[method]) {
- return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
- } else if (typeof method === 'object' || !method) {
- return methods.init.apply(this, arguments);
- } else {
- return $.error("Method " + method + " does not exist on jQuery.myownfunction");
- }
- }
- methods = {
- init:function(options, force){
- ....
- ......
- this.treetable(options, force);
- }
- otherfunction:
- .....
- ..............
- }
A work around, but not effectively. Is there any other good way to fix the subject? thanks a lot