eZ Community » Forums » Extensions » load more libraries with ezjscore
expandshrink

load more libraries with ezjscore

load more libraries with ezjscore

Friday 03 December 2010 2:23:15 am - 5 replies

I'm working in a new extension and I am using ezjscore. The question I have is whether they can add other libraries besides JQuery and YUI for inclusion with ezscript_load.

Friday 03 December 2010 9:32:12 am

Hello,

You can add other scripts adding a design.ini.append.php file in the settings directory of your extension.

like this :

[JavaScriptSettings]
JavaScriptList[]=mynew.js

Friday 03 December 2010 1:07:29 pm

If you want to do dynamic CDN vs local loading based on settings, then you can look at how Damien did it for jqueryUI in admin2pp project (this is similar to how ezjscore does it for yui2/3 and jquery, look at ezjscore.ini in admin2pp).

Also, if you use the setting from reply above, notice that in 4.3 two new settings was introduced so you have to specify if lib should be loaded in frontend or backend, the setting above worked in both front and back before, but you'll have to use BackendJavaScriptList[] in 4.3 and up to get it to load in admin2 design (backend). And can similary use FrontendJavaScriptList[] for frontend.

Modified on Friday 03 December 2010 1:12:15 pm by André R

Friday 03 December 2010 3:45:04 pm

Thanks for the reply.
I have the following problem, I have a search function but I get the following error message when I call.
EzjscServerRouter Not a valid argument: "socialnetwork:: search"
-------------------------------------------------- -----------------------------------
Invocation from the template:
jQuery.ez ("socialnetwork:: search ', {arg1:' hi!"}, function (data) {
if (data.error_text)
alert (data.error_text)
else
alert (data.content)
});
-------------------------------------------------- -----------------------------------
-------------------------------------------------- -----------------------------------
"Ezjscore.ini.append.php"
[EzjscServer]
FunctionList [] = socialnetwork
[EzjscServer_socialnetwork]
Class = LGKServerFunctions
Functions [] = socialnetwork
# PermissionPrFunction = disabled
File = extension / socialnetwork / classes / LGKServerFunctions.php
-------------------------------------------------- -----------------------------------
-------------------------------------------------- -----------------------------------
"LGKServerFunctions.php"
class LGKServerFunctions extends ezjscServerFunctions{
public static function search ($ args) {
if (isset ($ args [0])) {
return 'Hello World, you sat me parameter:'. $ Args [0];
Else {}
$ Http = eZHTTPTool:: instance ();
if ($ http-> hasPostVariable ('arg1')) {
return 'Hello World, you sat me post'. $ Http-> postVariable ('arg1');
}
}
return "Request to server completed, But You Did not send Any post / function parameters!"
}
}
-------------------------------------------------- -----------------------------------
The strange thing is that under the invocation of the template I have another
jQuery.ez ('ezjsc:: time', {postData: "hi!"}, function (data) {alert (data.content)});
and it works.

Friday 03 December 2010 4:19:10 pm

As the errormessage states: Not a valid argument: "socialnetwork:: search"

There is a space-character between :: and search. Or isn't it?

The following call to ezjsc::time is not being called, as the javascript was failing above?!?

Friday 03 December 2010 5:04:22 pm

The whitespace was error only in the post, in the source code is well written.

The call to ezjsc::time is done regardless of the failure of the other call (socialnetwork::search).

thanks

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from