Editing
Binding JQuery Handlers
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=Overview= Documentation describing how to set up JQuery handlers for CMS pages. =JavaScript libraries= ==Location== * As much as possible, re-use the generic handlers found in <code>cms.js</code>. * Code specific to a particular content type should go in <code>[SECTION_BASE_DIR]_scripts/[SECTION_NAME].js</code>. * Code should be [http://javascriptcompressor.com compressed] before uploading to production. * Uncompressed code should be stored in <code>[SECTION_BASE_DIR]_scripts/[SECTION_NAME]-source.js</code> which is on the local server but not uploaded to production. ==Binding routines== * Binding routines are defined as JQuery plugins. <syntaxhighlight lang="javascript"> (function ($) { var methods = { bindListingsHandlers: function() { return this.each(function() { /* binding logic goes here... */ }); }, bindListingsButtons: function() { return this.each(function() { /* binding logic goes here... */ }); } }; $.fn.[CONTENT_NAMESPACE] = function( method ) { /* method calling logic */ 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.[CONTENT_NAMESPACE].'); } return (false); }; }) ( jQuery ); </syntaxhighlight> * The routines are then attached to page elements after the document content is loaded: <syntaxhighlight lang="javascript"> $(document).ready(function() { $('#listings-container').[CONTENT_NAMESPACE]('bindListingsHandlers'); }); </syntaxhighlight> [[Category:CMS Documentation]] [[Category:JQuery/AJAX]]
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information