jQuery Mobile CSS version: 1.2.0
The HTML for my form is:
- <form id="account-add" data-ajax="false" autocomplete="off">
- <div data-role="fieldcontain" class="ui-hide-label">
- <label for="custom-name">
- </label>
- <input id="custom-name" name="custom-name" placeholder="" value="<?=$serviceName;?>" type="text">
- </div>
- <div data-role="fieldcontain" class="ui-hide-label">
- <label for="custom-<?=$fieldsArray['Username'];?>">
- </label>
- <input id="custom-<?=$fieldsArray['Username'];?>" name="custom-<?=$fieldsArray['Username'];?>" placeholder="" value="<?=$valuesArray['Username'];?>" type="text" onblur="if(this.value == '') { this.value = 'User ID'; }">
- </div>
- <div data-role="fieldcontain" class="ui-hide-label">
- <label for="custom-<?=$fieldsArray['Password'];?>">
- </label>
- <input id="custom-<?=$fieldsArray['Password'];?>" name="custom-<?=$fieldsArray['Password'];?>" placeholder="" value="<?=$valuesArray['Password'];?>" type="password" onblur="if(this.value == '') { this.value = 'Password'; }">
- </div>
- <input type="hidden" name="action" value="edit-2">
- <input type="hidden" name="accounteditid" value="<?=$accountEditId;?>">
- <input type="hidden" name="userid" value="<?=$userId;?>">
- <input id="account-edit-submit" type="submit" name="account-edit-submit" value="Update Account">
- </form>
It is dynamically loaded by:
- $("#account-input-holder").html(ajaxData).trigger("create");
Into the pre-existing HTML:
- <div data-role="page" id="page-addedit" style="overflow-x:hidden;">
- <div data-theme="a" data-role="header" data-position="fixed">
- <div data-role="content" style="width:100%; padding:1% 0 1% 0; text-align:center;">
- <img src="img/header-logo.png" style="width:60%;">
- </div>
- <div data-role="navbar" data-iconpos="false">
- <ul>
- <li>
- <a href="#page-home" data-theme="b" data-icon="false">
- <img src="img/navigation-home.png" style="height:30px;"><br>
- Home
- </a>
- </li>
- <li>
- <a href="#page-vault" data-theme="b" data-icon="false" class="ui-btn-active ui-state-persist">
- <img src="img/navigation-vault.png" style="height:30px;"><br>
- Accounts
- </a>
- </li>
- <li>
- <a href="#page-account" data-theme="b" data-icon="false">
- <img src="img/navigation-settings.png" style="height:30px;"><br>
- Settings
- </a>
- </li>
- <li>
- <a href="#page-help" data-theme="b" data-icon="false">
- <img src="img/navigation-help.png" style="height:30px;"><br>
- Help
- </a>
- </li>
- </ul>
- </div>
- </div>
- <div data-role="content">
- <a href="#page-search" id="button-back-addedit" data-role="button" data-appintent="pagechange" data-icon="back">
- Go Back
- </a>
- <div data-role="content" id="account-form-result" style="display:none;"></div>
- <div data-role="content" id="account-input-holder" style="margin:0; padding:0;">
- </div>
- </div>
- </div>
I've noticed that if I remove all but one (any one) of the first three fields (fieldcontain divs can remain and it doesn't affect this), the text update always works. I can focus and unfocus the field all day long and it will always update. But once I include the other two inputs, if I switch between them, eventually the fields stop updating.
Any idea what could be causing this and what I can do to resolve it? I never expected that something simple like text input would give me issues. Note that even if I turn off input enhancing by using "data-role='none'", the problem still occurs.
I noticed in the documentation that this code is provided for dynamically-generated forms:
- $( ...new markup that contains widgets... ).appendTo( ".ui-page" ).trigger( "create" );
Should I be using this instead of $(-containing-field-here-).html(-the-form-html-).trigger("create")? I use that code so I can replace the entire HTML of the containing DIV rather than the example code which appends the form, but I can always clear the containing DIV then append the form through the suggested code, but I am not sure if this makes a difference.