2

I have a html page (inicio.html) which loads some js scripts. Then from a js script there is a navigation to another page in a different html file (test.html) and a different set of js files.

The problem is that when I do the changePage ($.mobile.changePage("test.html");) and the new page is loaded the new js files are kept in files like http://localhost:8080/cdmWEB/resources/scripts/jquery/2.0.3/jquery-2.0.3.min.js/eval/seq/2

The js functions are being executed because the console.log messages in them are shown. But the changes the js scripts should do in the page are not rendered and the js cannot be debuged (using firebug).

I am loading the js scripts with the tag in the html file, but I have also tried the $.getScript function with the same result. I am using jQuery 2.0.3 and jQuery-mobile 1.3.1.

From what I saw the reason why the js files are kept like that is because they are retrieved using ajax. Is there a way to prevent this and retrieve the file "normally"? or is there something I am missing (probably)?

krishwader
  • 11,341
  • 1
  • 34
  • 51
aleviera
  • 67
  • 7
  • Cannot be debugged? How come? Just put a `debugger` in there. – Šime Vidas Aug 08 '13 at 14:52
  • The breakpoints I put in firebug are not considered. The page (test.html), if loaded directly instead of navigating from the other page (inicio.html), is loaded as usual, js files appear with their original names and firebug can debug them. The problem is not (I think) debugging the js files but knowing why they are being loaded differently and maybe preventing it. – aleviera Aug 08 '13 at 14:57
  • Put js files inside _page div_ not in _head_ tag. Also, it's better using jquery 1.9 not 2.0.3 – Omar Aug 08 '13 at 15:30
  • I have noticed that js code inside the page div is executed differently depending on whether the overall page was the first page loaded in the jqm framework or a subsequent page. If it's the first page then that code is only ever executed ONCE. if it's a subsequent page(s) then that code is executed every page load (regardless of from cache or new). – Drew Aug 08 '13 at 20:23

2 Answers2

1

Have a look here:

Jquery Mobile - $.mobile.changepage not loading external .JS files

You should consider loading the needed JS in the main page, and not in the page your changing to.

Community
  • 1
  • 1
jbkkd
  • 1,510
  • 5
  • 18
  • 37
  • That solves the problem of the js files being loaded differently. Now they are loaded as "usual" and can be debuged by firebug. Still, the changes I make to the page are not being rendered. I am using $('#cabezal').append(...);$('#cabezal').trigger('create'); – aleviera Aug 08 '13 at 15:10
0

I ended up using window.open('test.html','_self','',true); to make the transition. This loads the new scripts when the transition is made and the jquery appends keep working fine.

aleviera
  • 67
  • 7