Closed joaoventura closed 10 years ago
I'll remove watch.js as its not used at all... what are the instabillities that you see in chrome? Maybe there are other collisions. I want to put all webqlchemy js into a namespace to avoid these cases
Basically, with jquery mobile, and even without watch.js, sometimes the Chrome browser does not render the jquery mobile content immediately. But if I resize the browser window, minimize/maximize, or open Developer Tools (with F12), suddenly, it renders the jquery mobile content. It seems that the change in the window triggers an event which starts rendering the jquery mobile content.
This only happens in Chrome. In Firefox, it works fine.. Tomorrow, I will post here a ready example for you to try in your computer.
I've created a simple example to test this collision thing:
This is my main.html. It is the same as yours, but includes some divs for a jquery mobile page app. Notice that js/watch.js is commented.
<!DOCTYPE html>
<html>
<head>
--> stylesheets
--> include
--> meta
</head>
<body onload="init_communication()">
<div id="mypage" data-role="page">
<div id="header" data-role="header">Header</div>
<div id="main" data-role="main"></div>
<div id="footer" data-role="footer" data-position="fixed">Footer</div>
</div>
</body>
<script>
// the following files will be inserted here
// this is good to serve via a websocket. Can be removed
// if app is to be frozen
--> js/reconnecting_ws.js
//--> js/watch.js
--> js/cookie.js
--> js/vendor.js
--> js/comm.js
--> js/reconnection_overlay.js
--> js/download_url.js
--> js/classy.js
--> js/weba.js
// the following is good for freezing the app
--> websocket
</script>
</html>
This is my python file. Basically, it "catches" the main "div" and adds some content. Since you are adding this content after the page creation, you will have to call jQuery's "create" method to recreate the mobile layout.
from webalchemy import server
class HellowWorldApp:
stylesheets = ['http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css']
include = ['http://code.jquery.com/jquery-1.10.2.min.js',
'http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js']
def initialize(self, **kwargs):
self.rdoc = kwargs['remote_document']
main = self.rdoc.getElementById('main')
main.element(h1="Main content")
main.element(button="A button")
self.rdoc.JS('jQuery(' + main.varname + ').trigger("create")')
if __name__ == '__main__':
# this import is necessary because of the live editing. Everything else works OK without it
from helloworld import HellowWorldApp
server.run(HellowWorldApp)
With this, it works both in Chrome and Firefox, if js/watch.js is commented. I cannot reproduce the instability of Chrome anymore, maybe I broke something while messing around yesterday.
So, it seems you just need to remove "watch.js", and it will work fine.
I just removed watch.js, it was not used anywhere.
Note you can write the last line of the initialize
method above in a better way, which is not documented of course:
self.rdoc.JS('jQuery(#{main}).trigger("create")')
the varname of main is escaped this way...
Using js/watch.js in main.html throws an Uncaught TypeError when jquery mobile 1.4 is being used.
This is the following trace
Removing watch.js fixes the problem in Google Chrome (although the jquery mobile rendering seems unstable in Chrome with webalchemy).
This has no problem in Firefox..