javascript – 没有调用JQuery _renderItem
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – 没有调用JQuery _renderItem,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1515字,纯文字阅读大概需要3分钟。
内容图文
![javascript – 没有调用JQuery _renderItem](/upload/InfoBanner/zyjiaocheng/744/4a074529b6d941eaa46b0498009a724e.jpg)
我正在尝试使用_renderItem函数创建一个自定义的ui-menu-item元素但是在尝试之后我甚至无法调用该函数.自动完成工作正常,但它就像_renderItem函数不存在.这是我的脚本scction
<script language="Javascript" type="text/javascript">
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$j(document).ready(function() { //START of ready function
$j( "#custom-report" )
.autocomplete({
source: function( request, response ) {
$j.getJSON( "<?=$this->url(array("controller"=>"report", "action"=>"custom-autocomplete"))?>", {
term: extractLast( request.term )
}, response );
},
search: function() {
//Place holder
},
focus: function (event, ui) {
// Prevent the default focus behavior.
event.preventDefault();
},
select: function( event, ui ) {
var terms = split( this.value );
terms.pop();
terms.push( ui.item.value );
this.value = terms.join( ", " );
return false;
}
}).data("autocomplete")._renderItem = function (ul, item) {
return $("<li />")
.data("item.autocomplete", item)
.append("This is the text")
.addClass("tip")
.attr("desc", "This is the description")
.appendTo(ul);
};
}); //END of ready function
</script>
任何人都知道为什么这不起作用?
解决方法:
我最终不得不这样做
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.addClass("tip ui-menu-item")
.append("<a>" + item.label + "</a>")
.attr("desc", item.description) /* This is the filed that started the whole thing */
.attr("role", "presentation")
.appendTo(ul);
};
内容总结
以上是互联网集市为您收集整理的javascript – 没有调用JQuery _renderItem全部内容,希望文章能够帮你解决javascript – 没有调用JQuery _renderItem所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。