0

http://ubilabs.github.com/geocomplete/を使用して、フォームに緯度と経度を送信させています。以下のトリガーを実行するだけで機能し、緯度と経度のフィールドがいっぱいになります。ただし、submit jquery コードを追加すると、空白のフィールドが送信されます。フィールドがいっぱいになっているのに POST 経由で送信されていないことがわかるので、タイミングのことはわかっています。しかし、私はそれを理解できません、何か提案はありますか?

<script>
  $(document).ready(function(){
  // Area for any jQuery
    $("#geocomplete").geocomplete({
      details: "form",
      types: ["geocode", "establishment"]
    });

    $("#geoform").submit(function() {
      $("#geocomplete").trigger("geocode");
      alert('Handler for .submit() called.');
      return true;
    });
  });
</script>


<form id="geoform" method=post action="/foo.php">
  <input id="geocomplete" type="text" placeholder="Type in an address" value="Empire State Bldg" />
  <!--<input id="find" type="button" value="find" />-->
  <input type="submit" value="Go" />

  <fieldset>
    <input name="lat" type="text" value="">
    <input name="lng" type="text" value="">
    <input name="query" type="hidden" value="true">
  </fieldset>
</form>
4

1 に答える 1

3

送信機能からトリガーを削除し、遅延を追加しました。

<script>

      $(document).ready(function(){
      // Area for any jQuery
        $("#geocomplete").geocomplete({
          details: "form",
          types: ["geocode", "establishment"]
        });

        $("#submit-button").click(function() {
          $("#geocomplete").trigger("geocode");
          setTimeout("$('#geoform').submit();",500);
        });
      });
    </script>


    <form id="geoform" method=post action="/foo.php">
      <input id="geocomplete" type="text" placeholder="Type in an address" value="Empire State Bldg" />
      <!--<input id="find" type="button" value="find" />-->
      <input id="#submit-button" type="button" value="Go" />

      <fieldset>
        <input name="lat" type="text" value="">
        <input name="lng" type="text" value="">
        <input name="query" type="hidden" value="true">
      </fieldset>
    </form>
于 2013-03-29T04:40:32.560 に答える