Page 1 of 1

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

Posted: Wed Oct 02, 2013 11:43 pm
by macscripter
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);
        }
    }
});

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

Posted: Thu Oct 03, 2013 12:07 am
by support
   
// 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);
        }
    }
});
// 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);
        }
    }
});
   

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

Posted: Thu Oct 03, 2013 4:46 pm
by macscripter
oh yeah!!!!!!!! Working perfectly! Thank you!!!!!

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

Posted: Sun Nov 10, 2013 6:15 pm
by tomy300
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.

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

Posted: Mon Nov 11, 2013 5:33 am
by linb
Fixed, try again.