Jquery mobile dynamic fields not applying styles?
Hi i have creates a html page that creates dynamic fields and when i add them to the listview, it doesnt apply the jquery mobile themes.
here is my javascript:
- //Dynamically load data fields for items
- $(document).on('pagebeforeshow', '#claimPagefields', function(){
- //trigger a create event
- $('#claimPagefield').trigger('create');
- loadFields();
- });
Here is my HTML page
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
- <title></title>
- <link href="src/jquery.mobile-1.3.1.min.css" rel="stylesheet" type="text/css"/>
- <link rel="stylesheet" href="src/jquery.mobile.iscrollview.css" />
- <link rel="stylesheet" href="src/jquery.mobile.iscrollview-pull.css" />
- <script src="src/jquery-1.9.1.min.js" type="text/javascript"></script>
- <script src="src/jquery.mobile-1.3.1.min.js" type="text/javascript"></script>
-
- <script src="src/iscroll.js"></script>
- <script src="src/jquery.mobile.iscrollview.js"></script>
- <script src="src/script/itemFields.js"></script>
-
- <link rel="stylesheet" href="src/jquery.ui.datepicker.mobile.css" />
- <script src="src/jquery.ui.datepicker.js"></script>
- <script src="src/jquery.ui.datepicker.mobile.js"></script>
-
-
- </head>
-
- <body>
- <div data-role="page" id="claimPagefields">
- <div data-role="header" data-position="fixed" data-theme="b" data-tap-toggle="false" data-transition="none" > <a href="" onclick="history.back(-1); return false;">Back</a>
- <h1>New Claim</h1>
- </div>
- <div data-role="content">
- <ul class="ui-li" data-role="listview" id="claimTypelistfields" data-inset="true" data-scroll="true">
- <li data-role="list-divider">
- <h2 id="itemTitle">Title</h2>
- </li>
-
-
- </ul>
- <div data-role="navbar">
- <ul>
- <li><a href="some.html" data-theme="b">Save</a></li>
- </ul>
- </div>
- </div>
- </div>
- </body>
- </html>
It doesnt apply the theme on the input fields itself which typically look like this when i am adding it
- listItem = '<li id="reasons">' +
- '<h3>Reasons:</h3>' +
- '<div data-role="fieldcontain">' +
- '<input type="text" name="reasons" id="textFieldReasons" value="" />' +
- '</div>' +
- '</li>';
-
- $('#claimTypelistfields').append(listItem);
-
- $('#claimTypelistfields').listview('refresh');
If i manually add this snippet of code to the above input field manually
It works and resizes the width only but i am trying to see if there is way to apply it once instead of having to apply the themes all manually for each field!
Thanks