I’m using Symfony 2 and I need to execute a javascript just after the following twig template has loaded:
<div data-role="dialog">
<div data-role="header">
<h1>Input your Username and Password</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain" class="ui-hide-label">
<label for="username">Username:</label>
<input type="text" name="username" id="username" value="" placeholder="Username"/>
</div>
<div data-role="fieldcontain" class="ui-hide-label">
<label for="password">Password:</label>
<input type="password" name="password" id="password" value="" placeholder="password" />
</div>
<div data-role="controlgroup" data-type="horizontal" align="center">
<input type="button" value="Login"/>
<a data-rel="back" data-role="button"/>Cancel</a>
</div>
</div>
</div>
Normally, when we use jquery mobile, the main container of a page is a div with a datarole, set an id to this div and replace it with the divid in the script above and get u’re code working 🙂