javascript - jQuery Mobile Beta: can no longer use $('[data-role=header]')? -


i used able hold of

$('[data-role=header]').first().height() 

in alpha jquery 1.5.2, no longer can in beta jquery 1.6.1. has changed?

full code - writes 0 console.log...

<!doctype html>  <html>   <head>   <title>page title</title>   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" />  <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>  <script type="text/javascript"   src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>  <script type="text/javascript">  $(document).ready(function() {  console.log($('[data-role=header]').first().height());  });  </script> </head>  <body>  <div data-role="page" id="home">         <div data-role="header">        <h1>header</h1>        </div>  <div data-role="content">          //lots of code         </div>  </div>  </body> </html> 

however, change jquery 1.5.2 , jquery mobile alpha:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script> 

and writes non-zero height of header div.

incidentally, non-zero jquery 1.6.1 without jquery mobile. it's jquery mobile rendering.

can't see in release notes suggest might have happened, i'm no jquery expert.

looks did change of syntax, docs:

when finding elements jquery mobile data attribute, please use custom selector :jqmdata(), automatically incorporates namespaced data attributes lookup when in use. example, instead of calling $("div[data-role='page']"), should use $("div:jqmdata(role='page')"), internally maps $("div[data-"+ $.mobile.ns +"role='page']") without forcing concatenate namespace selectors manually.

try this:

$("div:jqmdata(role='header')").first().height() 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -