2010-02-11 78 views
1

我不是的jQuery的专家,我需要帮助移植这一功能帮助到移植函数原型 - > jQuery的1.4

auto_complete: function(controller, focus) { 
if (this.autocompleter) { 
    Event.stopObserving(this.autocompleter.element); 
    delete 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(); 

},

任何人都可以帮我吗?

+0

我们不在这里做你的工作。如果你有具体的问题,比如“jQuery中原型foo()的等价物”让我们知道。另外:为什么你需要把它移植到一个你不了解的框架? – 2010-02-11 14:03:45

回答

0

尽管使用了一些Prototype调用,但实际上大多只使用了自动完成器;你会想找到一个类似的jQuery小部件(在jQuery插件页面上有one listed),然后重写代码以使用该插件执行相同的操作。看起来主要是导航到“/ admin/mumble/id”,其中“mumble”是传入变量controller的值,“id”是在自动完成程序中选择的元素的ID。