jquery - How to namespace methods that do not belong in the actual plugin? -
jquery - How to namespace methods that do not belong in the actual plugin? -
i got extension points in plugin provide default implementations for. objects not belong in methods object should still namespaced properly.
how namespace extensions?
i tried this:
(function ($) { var pagemanagers = {}; var thememanagers = { }; thememanagers.notheme = { some: function() { } // , more. } var methods = { // of methods } $.fn.griffintable = function (method) { if (methods[method]) { homecoming methods[method].apply(this, array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { homecoming methods.init.apply(this, arguments); } else { $.error('method ' + method + ' not exist on jquery.griffintable'); } homecoming this; }; })(jquery);
but can't figure out how access pagemanagers
or thememanagers
outside like:
<script type="text/javascript"> $(function () { $('#mytable').griffintable({ fetchatstart: true, thememanager: thememanagers.notheme }); }); </script>
how namespace , utilize them?
i used outside jquery scope:
$.griffintableextensions = { pagemanagers: {}, thememanagers: {} };
which allows me use:
<script type="text/javascript"> $(function () { $('#mytable').griffintable({ fetchatstart: true, thememanager: $.griffintableextensions.thememanagers.notheme }); }); </script>
i committed table plugin: https://github.com/jgauffin/griffin.table
jquery jquery-plugins
Comments
Post a Comment