Use code in the third part scripts

Find code here before you post.

Use code in the third part scripts

Postby support » Mon Mar 11, 2019 6:05 pm

Suppose you have a script like this ( in ThirdPart/scripts/myscript.js ):

javascript code
// An unique namespace is important

MyScript.User = function(name){ = name || "No Name";
MyScript.User.prototype.sayHi = function (msg){
alert("To " + + ": " + (msg||"Hi") );

You can include and call the inner functions :

javascript code
xui.Class('App', 'xui.Module',{
iniComponents : function(){
// [[Code created by CrossUI RAD Studio
var host=this, children=[], append=function(child){children.push(child.get(0));};

.setCaption("Say Hi to John")

return children;
// ]]Code created by CrossUI RAD Studio
_xui_ui_htmlbutton2_onclick:function(profile, e, src){
// 'MyScript.User' must be the unique namespce in myscript.js, it can be cached by this id whe you first call it
// Though, if you call xui.include it again, the system will get it from cache, won't get it from the script again
xui.include('MyScript.User','ThirdPart/scripts/myscript.js', function() {
var john = new MyScript.User("John");
}, function(err) {
xui.alert('fail:' + err);
} );
Posts: 352
Joined: Sat Apr 27, 2013 9:22 am

Return to CrossUI Code Snaps

Who is online

Users browsing this forum: No registered users and 0 guests