submitの置き換えとval()で値を取る方法 | jquerymobile

同じ問題でreadyを使っているものが多かったのですが、

http://jquerymobile.com/test/docs/api/events.html

Important: Use pageInit(), not $(document).ready()

ということでこう書きました。

$( ‘#page_main’ ).live( ‘pageinit’,function(event){
$(‘#search_form’).unbind(‘submit’).bind(‘submit’, function(){search();});
});

#page_mainは、data-role=pageのIDです。
submitをunbindしていますが、追加だけで良い場合は、要りません。
ここでsearch()を読んでいるのですが、ここでbindした場合、 search()関数内の$(“#input_id”).val(); は有効になります。
他でsearch();を読んでもval()で取得することは出来ませんでした。

http://jquerymobile.com

のサンプルを見ているとhtml5の勉強にもなって面白いですね。

=== ajaxで取得するとid指定した物が2つになる・・・同じelementが増えていく? ===

ajaxでの遷移を停止する。
* formタグに data-ajax=”false”
* aタグに rel=”externals”
* jquery と jquerymobileの間に設定コードを書く。
<script src=”http://code.jquery.com/jquery-1.6.4.min.js”></script>
<script type=”text/javascript”>
$(document).live(“mobileinit”, function() {
$.mobile.ajaxEnabled = false;
$.mobile.ajaxLinksEnabled = false;
$.mobile.ajaxFormsEnabled = false;
});
</script>
<script src=”http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js”></script>

* changepageのときのajaxをやめたい・・・
と思ったのですが。

そうじゃなくて、pageのidをちゃんと管理しないといけないみたいですね。
修正が必要です。

This entry was posted on 火曜日, 1月 31st, 2012 at 2:37 PM and is filed under html5, jquery mobile. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。