私はDOM構造に従っています
<form name="address_form" method="post">
<input type="hidden" name="action" value="update_address_details">
<input type="hidden" name="latitude" value="52.367659">
<input type="hidden" name="longitude" value="-0.409539">
<input type="hidden" name="map_zoom_point" value="14">
<input type="text" name="address" value="" value="brington"> //visible element
<input type="submit" name="submit" value="Update"/> //visible element
</form>
form
このフォームの下にある DB で利用可能なデフォルトの入力データをユーザーにlatitude
示してlongitude
いますmap_zoom_point
。
ユーザーが OpenLayers マップ上のマーカー画像を移動すると、上記のフォームの非表示フィールドが自動的に更新されるため、jQuery を使用してこの変更をキャプチャしたいと考えています。以下のコードを使用すると、
$('form[name=address_form] input').on('change keypress',function() {
console.log('something');
});
ユーザーがアドレスフィールドのテキストを変更した場合にconsole.log
のみ印刷されます。それ以外の場合は、隠しフィールドが変更されてもログメッセージは印刷されません。