On Sun, Oct 14, 2012 at 10:55 AM, Boudjelda Mohamed Said <[email protected]> wrote:
Hi XWiki users
I wanted to add a jQuery library from CDN so I added <script> tag inside {{html}} macro this way :
{{velocity}} {{html clean="false"}} <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js "></script> </head>
{{/html}} {{/velocity}}
Note that whatever you put in the content of a wiki page the result is inserted in the BODY tag of the final HTML page so generating the HEAD tag in the content of a wiki page is wrong. Your best option is to load the JavaScript and CSS dynamically following this steps: (1) Define a JavaScript/CSS extension. See http://platform.xwiki.org/xwiki/bin/view/DevGuide/SkinExtensionsTutorial . (2) For CSS you simply use @import. For JavaScript you listen to page load and then inject a SCRIPT tags in the existing HEAD of the HTML page. document.observe('xwiki:dom:loaded', function() { // Inject the script tag here. }) (3) Whenever you need the JavaScript/CSS you use {{velocity}} #set ($discard = $xwiki.ssx.use('Space.PageWithSSX')) #set ($discard = $xwiki.jsx.use('Space.PageWithJSX')) {{/velocity}} You may want to take a look at http://extensions.xwiki.org/xwiki/bin/view/Extension/jQuery+Helpers . Also note that we're using Prototype.js in XWiki everywhere so you need to handle the conflicts with jQuery. Hope this helps, Marius
I could not use jQuery and it gives me this error in console.
Refused to execute a JavaScript script. Source code of script found within request Resource interpreted as Script but transferred with MIME type text/html: "about:blank".
any way to use js libraries and css from CDN ??
Thanks _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users