复制的步骤:
我创建了一个hai.html并使用pagemod i注入脚本,这是代码,hai.html https://github.com/suneeshtr/suneeshtr/trigger-test.git-test.git
实际结果:
注入脚本,除了触发外,一切都很好。当我尝试附加文件时,它可以工作..
这是代码的一部分:
alert("content");
$(document).ready(function() {
var values = [{val:'santiagotactivos', meta:'Santiago Montero'},
{val:'johnnyhalife', meta:'Johnny Halife'},
{val:'arielflesler', meta:'Ariel Flesler'},
{val:'rbajales', meta:'Raul Bajales'}];
var customItemTemplate = "<div><span /> <small /></div>";
function elementFactory(element, e) {
var template = $(customItemTemplate).find('span')
.text('@' + e.val).end()
.find('small')
.text("(" + e.meta + ")").end();
element.append(template);
};
alert(JSON.stringify($("textarea")));
// here is how we use it
$('textarea').sew({values: values, elementFactory: elementFactory});
});
您的问题不清楚,您可以尝试此示例
var src = [{val:'santiagotactivos', meta:'Santiago Montero'},
{val:'johnnyhalife', meta:'Johnny Halife'},
{val:'arielflesler', meta:'Ariel Flesler'},
{val:'rbajales', meta:'Raul Bajales'}];
$("#auto").autocomplete({
source:src
});
也尝试一下:
http://www.hawkee.com/snippet/9391/
$('#inputbox').triggeredAutocomplete({
hidden: '#hidden_inputbox',
source: "/search.php",
trigger: "@"
});