开发者

JQuery search no longer working

开发者 https://www.devze.com 2023-02-02 02:00 出处:网络
I cannot figure out why this isn\'t working.It\'s a JQuery search box that uses the Freebase API to find games.When I POST, the gameID and gameName are blank.

I cannot figure out why this isn't working. It's a JQuery search box that uses the Freebase API to find games. When I POST, the gameID and gameName are blank.

<link type="text/css" rel="stylesheet" href="http://freebaselibs.com/static/suggest/1.3/suggest.min.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://freebaselibs.com/static/suggest/1.3/suggest.min.js"></script>
<script type="text/javascript">
      $(function() {
        $("#game-search").suggest({type:'/games/game'}).bind("fbSelect", function(e, data) {
        $("#game-id").val(data.id);
        $("#game-name").val(data.name);
        });
      });
</script>


<form name="input" action="/game-profile" me开发者_如何转开发thod="post">
  <input class="search-box" name="fbSelect" type="text" id="game-search"/>
  <input type="hidden" name="gameID" id="game-id" />
  <input type="hidden" name="gameName" id="game-name" />
  <input class="button" value="Go" type="submit"/>
</form>


I grabbed your code and changed the hidden fields to type="text" just so I could see the data when a selection was made from the auto-complete. The fields weren't being populated on select, so I took a quick peek at the API.

It looks like the event you should be binding to is fb-select rather than fbSelect a la:

  $(function() {
    $("#game-search").suggest({type:'/games/game'}).bind("fb-select", function(e, data) {
    $("#game-id").val(data.id);
    $("#game-name").val(data.name);
    });
  });


It doesn't look like the fbSelect event you're binding to, ever gets fired. Have you included all required code parts for this to work?

(Answered retrospectively via comment on original question. @borkweb is more correct.)

0

精彩评论

暂无评论...
验证码 换一张
取 消