0
我在我的插件中有一些擴展點,我提供了一些默認實現。這些對象不屬於我的方法對象,但仍應正確命名空間。如何命名空間不屬於實際插件的方法?
如何爲這些擴展命名空間?
我試着這樣做:
(function ($) {
var pageManagers = {};
var themeManagers = { };
themeManagers.noTheme = {
some: function() {
}
// and more.
}
var methods = {
// all of my methods
}
$.fn.griffinTable = 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 {
$.error('Method ' + method + ' does not exist on jQuery.griffinTable');
}
return this;
};
})(jQuery);
但我無法弄清楚如何從外部訪問pageManagers
或themeManagers
,如:
<script type="text/javascript">
$(function() {
$('#mytable').griffinTable({ fetchAtStart: true, themeManager: themeManagers.noTheme });
});
</script>
如何命名空間和使用它們?