|
|
|
|||||||||||||||||||||||||||||||
![]() |
JQuery Coding StandardsFollow Drupal’s JavaScript coding standardsOn this page:
ShorthandsUse the jQuery shorthand$ where possible:
$(function() { ... }); instead of
$(document).ready(function() { ... });
Wrap
|
Name | Content![]() |
---|---|
foswiki.pubUrl | %PUBURL% |
foswiki.pubUrlPath | %PUBURLPATH% |
foswiki.scriptUrl | %SCRIPTURL% |
foswiki.scriptUrlPath | %SCRIPTURLPATH% |
foswiki.serverTime | %SERVERTIME% |
foswiki.systemWebName | %SYSTEMWEB% |
foswiki.topic | %TOPIC%" |
foswiki.loginName | %USERNAME% |
foswiki.usersWebName | %USERSWEB% |
foswiki.web | %WEB% |
foswiki.wikiName | %WIKINAME% |
foswiki.wikiUserName | %WIKIUSERNAME% |
foswiki.ImagePluginEnabled | %IF{"context ImagePluginEnabled" then="true" else="false"}% |
foswiki.MathModePluginEnabled | %IF{"context MathModePluginEnabled" then="true" else="false"}% |
var
before they are used.
var object = { foo: 'bar' }not
var object = { foo: 'bar', }
Use JQueryMetadata to integrate jQuery plugins into Foswiki.
Use JQueryLiveQuery to initialize your plugin for all html elements of a page. Otherwise content that is loaded asynchronously using ajax won't be initialized. LiveQuery will take care of that automatically.
Instead of
$(".jqPluginName").each(function() { // initializer });
use
$(".jqPluginName").livequery(function() { // initializer });
See JQueryMetadata for a more thorough example of useing metadata and livequery