开发者

Help to porting function prototype -> jquery 1.4

开发者 https://www.devze.com 2022-12-19 17:50 出处:网络
I\'m not an expert of jquery and i need help to porting this function auto_complete: function(controller, focus) {

I'm not an expert of jquery and i need help to porting this function

auto_complete: function(controller, focus) {
if (this.autocompleter) {
  Event.stopObserving(this.autocompleter.element);
  dele开发者_高级运维te this.autocompleter;
}
this.autocompleter = new Ajax.Autocompleter("auto_complete_query", "auto_complete_dropdown", "/admin/" + controller + "/auto_complete", {
  frequency: 0.25,
  afterUpdateElement: function(text, el) {
    if (el.id) {
      window.location.href = "/admin/" + controller + "/" + escape(el.id);
    } else {
      $("auto_complete_query").value = "";
      window.location.href = window.location.href;
    }
  }
});
$("auto_complete_dropdown").update("");
$("auto_complete_query").value = "";
if (focus)
  $("auto_complete_query").focus();

},

Anyone may help me?


Although that uses some Prototype calls, that's actually mostly just using a script.aculo.us auto-completer; you'll want to find a similar widget for jQuery (there's one listed on the jQuery plug-ins page) and then rewrite the code to do the same thing using that plug-in. Looks like mostly what it does is navigate to "/admin/mumble/id" where "mumble" is the value of the pass-in controller variable and "id" is the ID of the element chosen in the auto-completer.

0

精彩评论

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