Software Archive
Read-only legacy content
17061 Discussions

Cannot call function from Index_user_script.js - Why?

ben4
Beginner
307 Views

Hello,

 

I am having a lot of problems trying to get a function to kick in when my sidebar close button is clicked.

 

in the Intel Sdk there is apart that shows this:

        /* listitem  Close Side bar */
    $(document).on("click", ".uib_w_17", function(evt)
    {
         /*global uib_sb */
         /* Other possible functions are: 
           uib_sb.open_sidebar($sb)
           uib_sb.close_sidebar($sb)
           uib_sb.toggle_sidebar($sb)
            uib_sb.close_all_sidebars()
          See js/sidebar.js for the full sidebar API */
        
         uib_sb.toggle_sidebar($(".uib_w_1")); 
         setTimeout(show_interstitial_app, 3000);<--My function
         return false;
    });

 

 

In the index.html file I created  a function as:

function show_interstitial_app(){
    AdMob.createBanner( {
    adId: admobid.banner,
    position: AdMob.AD_POSITION.BOTTOM_CENTER,
    isTesting: true, // TODO: remove this line when release
    overlap: false,
    offsetTopBar: false,
    bgColor: 'black'
  } );
    
}

 

 

I am not asking any help about the code itself, but why I cannot call my function

setTimeout(show_interstitial_app, 3000);

 (from another js file) using the Index_user_script.js?

 

Where is the catch please as I cannot work this one out....

I am just trying to get a delay on an interstitial ad from ad mob cordova, thats all.

 

 

Thanks.

 

Ben

0 Kudos
4 Replies
Diego_Calp
Valued Contributor I
307 Views

Hi Ben,

Try placing your function in app.js file.

Because index.html is modified a lot by Designer, seems better to me to place the code in files that are only manually edited.

Regards,

Diego

0 Kudos
ben4
Beginner
307 Views

Thanks, unfortunately I cannot because it has to be placed in the body of the app.

0 Kudos
Diego_Calp
Valued Contributor I
307 Views

This is strange, I added this function into index.html:

<script>
function test(){console.log('hello');}
</script>

In three places: between body tags and before and after the including of index_user_script.js on header tag. And in all places it works.

But my tests were only with Simulator.

Did you check the console for errors?

0 Kudos
ben4
Beginner
307 Views

Yes earlier on I tried to include this ad code above the body and on the mobile, no ads were showing. This is why I am forced to add this code in the body itself. No problem I have done it and it is working now:-)

0 Kudos
Reply