Software Archive
Read-only legacy content

Designer throws js at bottom away

Evert_G_
Beginner
860 Views

Hi,

My *_user_script.js contains code that needs to be executed when the page has been loaded.
I put these files along with some others at the end of the html file.
A change in the file via the designer does not preserve these files.

Rather annoying.

Regards,

Evert

0 Kudos
4 Replies
Chris_P_Intel
Employee
860 Views

Hmm. I'm not following exactly what you are doing.

 

If I put <script src="majic.js"></script> right before </body>, then that file stays there for most operations. If I add some pages I might get them added after the script, but the script remains undisturbed.

Is this what you are seeing?  You mention the *_user_scripts.js file, but I'm not sure in what context.  Are you trying to move _that_ to the bottom of the HTML?

 

Are you using multiple .html files?  Normally, if you want something to load when the doc is ready , the best way to do this is not by making it the last script. The way to do this is by registering a function for app.Ready

document.addEventListener("app.Ready",your_handler, false);

or 

document.addEventListener("app.Ready", function(){

//do stuff here

}, false);

app.Ready gets called on DOMContentLoaded, or when the Cordova ready is fired (whichever is last) as well as other cases. The only time you might not want to use app.Ready is if you are working with multiple .html files, in which case the first one (index.html) should use app.Ready and the others should just use $(document).ready()

0 Kudos
Evert_G_
Beginner
860 Views

Hi,

Well, yes, I'm moving _that_ to the bottom.
Then I change some css in the designer, and then the script is gone.

Thanks for the good advice.
Though it doesn't solve the issue, it is an improvement. 

 

0 Kudos
Chris_P_Intel
Employee
860 Views

If you look at the main.less.css file it clearly states at the beginning that it is auto-generated and that any edits to it will be overwritten.

If you need to modify CSS, there are two ways to do this:

1 - Make your own .css file. This is what I recommend.  Just bind it in _after_ the main.less.css file and any CSS rules you put in it will normally override the others.

2 - Modify the original .less files.   Find index_main.less and make your changes there or in the files it references. Note, that you'll have to be careful, if you "break" the less then the CSS won't be compilable, and the designer will either make you fix it or restore the last working.

 

 

0 Kudos
Evert_G_
Beginner
860 Views

Hi Chris,

I am not editing the css nor less files directly.They are not the issue here. The javascriptfiles are.
Apparently there is a bug in the designer which causes to throw away the scripts at the end of the file once an element is regenerated in the designer.
I'll learn to live with it.

Thanks

0 Kudos
Reply