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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -