Software Archive
Read-only legacy content
17061 Discussions

methods declared on app.js doesnt work for me

Sergio_R_1
Beginner
264 Views

 

Hi! Incredible tool intel-xdk.

Im working a cordova project and noticed that code inside app.js is recognized by other js files. I added some "click" events and doesnt seem to find methods declared in app.js,

 

        <script src="cordova.js" id="xdkJScordova_"></script>

        <script src="js/app.js"></script>
        <!-- for your event code, see README and file comments for details (doesnt work for me!) -->
        <script src="js/init-app.js"></script>
        <!-- for your init code, see README and file comments for details -->
        <script src="xdk/init-dev.js"></script>
        <!-- normalizes device and document ready events, see file for details -->
        
        <script type="application/javascript" src="lib/jquery.min.js"></script>
        <script type="application/javascript" src="jqm/jquery.mobile-min.js" data-ver="0"></script>
        <script type="application/javascript" src="js/acceso_login_user_scripts.js"></script>

 

Eventought if i declare another js file just before my x_user_script.js file it works

        <script src="cordova.js" id="xdkJScordova_"></script>

        <script src="js/app.js"></script>
        <!-- for your event code, see README and file comments for details -->
        <script src="js/init-app.js"></script>
        <!-- for your init code, see README and file comments for details -->
        <script src="xdk/init-dev.js"></script>
        <!-- normalizes device and document ready events, see file for details -->
        
        <script type="application/javascript" src="lib/jquery.min.js"></script>
        <script type="application/javascript" src="jqm/jquery.mobile-min.js" data-ver="0"></script>
       <!-- here include a .js file with methods, and works! -->
        <script type="application/javascript" src="js/acceso_login_user_scripts.js"></script>

 

I suppose theres a initialization on init-dev.js that erases the previous js files. if this is a bug maybe the app.js file shouldnt be generated in fisrt place?

 

Thanks!

0 Kudos
1 Reply
Elroy_A_Intel
Employee
264 Views

I recommend moving your "click" event handler within the following code block:

$(document).ready(function(){
    $("#button").click(function(){
        //Code goes here
    });
}); 

This allows for the event handler to be assigned to an element with an id called button after the DOM is fully loaded. 

0 Kudos
Reply