javascript - Jquery Mobile. Markup and code structure of offline app -


i'm building offline application phonegap + jqm. app pages in separate files. sample of page file structure.

<div data-role="page" id="page2">    <script type="text/javascript">        ... necessary javascript create page content ...    </script>     <div data-role="header"><h3>header</h3></div>    <div data-role="content">content</div>    <div data-role="footer"><h3>footer</h3></div> </div> 

is way write js code inline page markup? me, clear , convenient. see , can write necessary code current page. don't want write code responsible creating page content in 1 file include in header. so, ok?

functionally end result same whether javascript inline on page or whether link it, can if want place javascript inline.

that said it's idea separate code markup, doing helps keep things more structured , makes easier reuse code. example in case can have page specific javascript file each of pages, javascript files each containing code might apply more 1 page can reuse in 1 of pages linking it.

the fact app offline shouldn't make difference far benefits of separating javascript goes.

i don't want write code responsible creating page content in 1 file include in header.

two things, first there no reason keep code in 1 file, use many necessary (in regular web page might want combine them before publishing since offline phonegap application don't think makes difference. second it's considered practice place javascript files on bottom of page doesn't block rest of page loading.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -