iframe コンテンツにメソッドを作成しようとするとcall .trigger('create')
、機能せず、css クラスが input:text 要素に適用されません。しかしcall .trigger('create')
、iframe の外側の html コンテンツに対してメソッドを実行すると、機能します。これが私のJavaScriptコードです。
var content = ' <form class="fbm_contactform">\
<div>Contact Us</div>\
<div data-role="fieldcontain"><label for="name" >Name</label>\
<input name="name" type="text" class="m-field" /></div>\
<div data-role="fieldcontain"><label for="email">Email</label>\
<input name="email" type="text" class="m-field" /></div>\
<div data-role="fieldcontain"><label >Message</label>\
<input name="message" type="text" class="m-field" /></div>\
<input name="submitButton" type="submit" class="m-field" value="Send Message" /></div>\
</form> ';
jQuery("#mobile_view").contents().find("#fbm_mob_menu").before(content);
jQuery("#mobile_view").contents().find(".fbm_contactform").trigger("create");
//console.log(jQuery("#mobile_view").contents().find(".fbm_contactform").html());
コンソール ログは正しい html コンテンツを出力します。