Call a javascript function defined in App/js/index.js html

Develop and Deploy Cross-Browser Web Apps .

Call a javascript function defined in App/js/index.js html

Postby macscripter » Wed Oct 02, 2013 11:43 pm

I have this code and my problem is I don't know hot to call a javascript function "greeting" from form defined in .setHtml function in "container" div...
Here is the code:
Code: Select all
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To initialize instance(e.g. properties)
        initialize : function(){
            // To determine whether or not the com will be destroyed, when the first UI control be destroyed
            this.autoDestroy = true;
            // To initialize properties
            this.properties = {};
        },
        // To initialize internal components (mostly UI controls)
        // *** If you're not a skilled, dont modify this function manually ***
        iniComponents : function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0))};
           
            append(
                (new xui.DataBinder)
                .setHost(host,"databinder_1")
                .setName("databinder_1")
            );
           
            append(
                (new xui.UI.SButton)
                .setHost(host,"ctl_sbutton1")
                .setLeft(130)
                .setTop(70)
                .setCaption("click me")
                .onClick("_ctl_sbutton1_onclick")
            );
           
            append(
                (new xui.UI.Div)
                .setHost(host,"container")
                .setLeft(130)
                .setTop(170)
                .setWidth(300)
                .setHeight(300)
            );
           
            append(
                (new xui.UI.Slider)
                .setHost(host,"ctl_slider23")
                .setLeft(310)
                .setTop(390)
                .setIsRange(false)
                .setValue("0")
            );
           
            return children;
            // ]]Code created by CrossUI RAD Tools
        },
        // Give a chance to load other com
        iniExComs : function(com, threadid){
        },
        // Give a chance to determine which UI controls will be appended to parent container
        customAppend : function(parent, subId, left, top){
            // "return false" will cause all the internal UI controls will be added to the parent panel
            return false;
        },
        // This instance's events
         events : {"onReady":"_com_onready"},
        _ctl_sbutton1_onclick : function (profile, e, src, value) {
            var uictrl = profile.boxing();
            xui.alert('value:' + document.getElementById('sp').checked);
        },
        hereDoc : function (f) {
              return f.toString().
        replace(/^[^\/]+\/\*!?/, '').
        replace(/\*\/[^\/]+$/, '');
                },
                greeting : function() {
        xui.alert('hola');   
        },
        _com_onready : function (com,threadid){
        var miHtml = this.hereDoc(function() {/*!
       <form class="form-signin">
        <h2 class="form-signin-heading">Please sign in</h2>
        <input type="text" class="form-control" placeholder="Email address" autofocus>
        <input type="password" class="form-control" placeholder="Password">
        <label class="checkbox">
          <input type="checkbox" value="remember-me"> Remember me
        </label>
        <button class="btn btn-lg btn-primary btn-block" type="button" onClick="greeting()">Sign in</button>
      </form>
            */});
            this.container.setHtml(miHtml);
        }
    }
});
macscripter
 
Posts: 21
Joined: Wed Apr 24, 2013 12:53 pm

Re: Call a javascript function defined in App/js/index.js ht

Postby support » Thu Oct 03, 2013 12:07 am

   
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
// Ensure that all the value of "key/value pair" does not refer to external variables
Instance:{
// To initialize instance(e.g. properties)
initialize : function(){
// To determine whether or not the com will be destroyed, when the first UI control be destroyed
this.autoDestroy = true;
// To initialize properties
this.properties = {};
},
// To initialize internal components (mostly UI controls)
// *** If you're not a skilled, dont modify this function manually ***
iniComponents : function(){
// [[Code created by CrossUI RAD Tools
var host=this, children=[], append=function(child){children.push(child.get(0))};

append(
(new xui.DataBinder)
.setHost(host,"databinder_1")
.setName("databinder_1")
);

append(
(new xui.UI.SButton)
.setHost(host,"ctl_sbutton1")
.setLeft(130)
.setTop(70)
.setCaption("click me")
.onClick("_ctl_sbutton1_onclick")
);

append(
(new xui.UI.Div)
.setHost(host,"container")
.setLeft(130)
.setTop(170)
.setWidth(300)
.setHeight(300)
);

append(
(new xui.UI.Slider)
.setHost(host,"ctl_slider23")
.setLeft(310)
.setTop(390)
.setIsRange(false)
.setValue("0")
);

return children;
// ]]Code created by CrossUI RAD Tools
},
// Give a chance to load other com
iniExComs : function(com, threadid){
},
// Give a chance to determine which UI controls will be appended to parent container
customAppend : function(parent, subId, left, top){
// "return false" will cause all the internal UI controls will be added to the parent panel
return false;
},
// This instance's events
events : {"onReady":"_com_onready"},
_ctl_sbutton1_onclick : function (profile, e, src, value) {
var uictrl = profile.boxing();
xui.alert('value:' + document.getElementById('sp').checked);
},
hereDoc : function (f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
},
greeting : function() {
xui.alert('hola');
},
_com_onready : function (com,threadid){
// Give it a global reference
window.APPInstance=this;
var miHtml = this.hereDoc(function() {/*!
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="form-control" placeholder="Email address" autofocus>
<input type="password" class="form-control" placeholder="Password">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-lg btn-primary btn-block" type="button" onClick="APPInstance.greeting()">Sign in</button>
</form>
*/});
this.container.setHtml(miHtml);
}
}
});
   
support
 
Posts: 352
Joined: Sat Apr 27, 2013 9:22 am

Re: Call a javascript function defined in App/js/index.js ht

Postby macscripter » Thu Oct 03, 2013 4:46 pm

oh yeah!!!!!!!! Working perfectly! Thank you!!!!!
macscripter
 
Posts: 21
Joined: Wed Apr 24, 2013 12:53 pm

Re: Call a javascript function defined in App/js/index.js ht

Postby tomy300 » Sun Nov 10, 2013 6:15 pm

Weird this code does't seem to work anymore, I see the loading progress...

I try to past this code directly same thing, I got no error in the code.
tomy300
 
Posts: 70
Joined: Sat Nov 09, 2013 12:27 am

Re: Call a javascript function defined in App/js/index.js ht

Postby linb » Mon Nov 11, 2013 5:33 am

Fixed, try again.
linb
Site Admin
 
Posts: 102
Joined: Thu Apr 25, 2013 6:51 am


Return to CrossUI for Web Apps

Who is online

Users browsing this forum: No registered users and 0 guests

cron