[ 
https://issues.apache.org/jira/browse/JSPWIKI-811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14124902#comment-14124902
 ] 

brushed commented on JSPWIKI-811:
---------------------------------

@David Vittor:

commonheader.jsp would indeed be a good place to insert the library.
Make sure to add it BEFORE mootools.js, as both libraries are using the common 
$ object.

Alternatively, you could also add following code snippet to the impacted JSP's:

{noformat}
<%
   WikiContext context = WikiContext.findContext( pageContext );
   WikiEngine engine = context.getEngine();

   TemplateManager.addResourceRequest( context, TemplateManager.RESOURCE_SCRIPT,
           context.getURL( WikiContext.NONE, "scripts/jquery-1.11.1.min.js" ) );
   TemplateManager.addResourceRequest( context, TemplateManager.RESOURCE_SCRIPT,
           context.getURL( WikiContext.NONE, 
"scripts/my-jquery-based-routines.js" ) );
%>
{noformat} 

BTW, this code can also be invoked by any plugin, when some kind of javascript 
is needed.


***

In order to  bootstrap the query javascript, you should avoid the use of 
window.onload().
It will limit your flexibility to have multiple on-load handlers,  and forces 
you to modify
the jspwiki-common.js.

Better is to inject additional 'on-load' event-handlers via jQuery.
All these event-handlers are invoked when the page loading is complete. 
This way, the jQuery based code can effectively run side by side with mootools.
And any other plugin can add its own on-load event-handlers if needed.

{noformat}
// my-jquery-based-routines.js

!function( $ ){

    // we are now in jquery land :  $ is now pointing to the jQuery $ object.   
 
    $(document).on('load',function() {
        $( "div" ).show();
    }

    //you can also borrow someone  elses jquery library, no need to convert all 
the "$" 

});

}( jQuery.noConflict() );

// and now we are back into mootools land

{noformat}


> Migrate from Mootools to jQuery
> -------------------------------
>
>                 Key: JSPWIKI-811
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-811
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Default template
>            Reporter: Ichiro Furusato
>              Labels: javascript
>             Fix For: FutureVersion
>
>
> Following a discussion on the dev mailing list, this is a suggestion to 
> migrate from Mootools to jQuery, given the latter's overwhelming popularity.
> Re: Mootools vs. jQuery, jspwiki-dev mailing list
> http://mail-archives.apache.org/mod_mbox/jspwiki-dev/201401.mbox/%3CCAEUnRMtqhu%3Drd5MfJ4mEJdDKn2bhMZkFKwMKogYyjfh%3D-j9ocA%40mail.gmail.com%3E



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to