私は多くの同様の質問を見ましたが、おそらく私の機能を呼び出す方法を理解できません。jQueryへのフォーム入力なしのSubmitボタンなしでの入力
私の目標は、ユーザーがフォームフィールドに入力してEnterキーを押して送信することです。
現在、誰かがフォームに値を入力した場合、[Enter]をクリックしても何もしません。実行するには、[在庫の検索]ボタンをクリックする必要があります。
私の検索フォームは簡略化されています...すべてがjquerydataのクラスを持つ多くのフィールドがあります。クラスinventory_search_db_connectは、jquerydataをクラスとしてすべてを収集し、その処理を行うjQuery関数にバインドされています。
<form method="post" action="" name="form3" id="form3">
<input type=text name="title" size=25 value="" class="jquerydata">
<input type=button class="inventory_search_db_connect" value=" Search Inventory" class="jquerydata">
</form>
ジャバスクリプト/ jQueryの
$(document).ready(function() {
pageBinds.db_actions();
SearchBinds.search_actions();
});
var pageBinds = {
db_actions: function() {
var that = this;
$('.inventory_functions_db_connect').on(
'click', function(event){
var query= $(this).closest('.parent').find('.jquerydata').serialize();
....does stuff here
);
},
unbind: function() {
$('.inventory_functions_db_connect').off();
this.db_actions();
}
}
私は
<form method="post" action="" name="form3" id="form3" onsubmit="return false">
を追加しました私もうまくいくかもしれない1は、formタグで
$(document).ready(function() {
$('#form3').on("submit", function() {
this.db_actions();
});
});
た、いくつかのことを試してみました私がここにいるので、これは明らかに悪くなかったk。
他の多くの回避策がありますが、私が望む機能を呼び出す方法を解読できませんでした。任意の洞察力を事前に
おかげで... マイク
使用 '$(文書を)助けを願っています。キーの押下(関数(e){if(e.which = 13){var query = $(this)).closest( '。親')find( '。jquerydata')。serialize(); ... ' – jcubic