|
@@ -771,9 +771,10 @@ function autocomplete()
|
|
|
minLength: 2,
|
|
|
source: function( request, response )
|
|
|
{
|
|
|
- var term = request.term;
|
|
|
- if ( term in cache ) {
|
|
|
- response( cache[ term ] );
|
|
|
+ var term = request.term.split( /,\s*/ );
|
|
|
+ request.term = term.pop();
|
|
|
+ if ( request.term in cache ) {
|
|
|
+ response( cache[ request.term ] );
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -800,18 +801,54 @@ function autocomplete()
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ focus: function() {
|
|
|
+ // prevent value inserted on focus
|
|
|
+ return false;
|
|
|
+ },
|
|
|
select: function( event, ui )
|
|
|
{
|
|
|
//log( "Selected: " + ui.item.value + " aka " + ui.item.id );
|
|
|
var value = self.attr('complete_callback');
|
|
|
var id = self.attr('id').replace('_temp', '');
|
|
|
- $("#" + id).val(ui.item[value]);
|
|
|
+ var name = self.attr('name').replace('_temp', '');
|
|
|
+ //var e = $("#" + id);
|
|
|
+ var e = self;
|
|
|
+ var html = '<div style="margin-top: 10px;width: 60%; overflow: auto;max-height: 500px;"><table id="'+id+'_show" class="table table-small-font table-bordered"></table></div>';
|
|
|
+ if (!$("#" + id + '_show').length) {
|
|
|
+ e.parent().append(html);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($("#" + id + '_show').html().indexOf(ui.item.value) == -1)
|
|
|
+ {
|
|
|
+ var link = '';
|
|
|
+ var attr = '';
|
|
|
+ var pic = '';
|
|
|
+ if (ui.item['pic']) {
|
|
|
+ pic = '<a href="javascript:;"><img src="'+ui.item['pic']+'" width="100"></a>';
|
|
|
+ }
|
|
|
+ if (ui.item['link']) {
|
|
|
+ link = ui.item['link'];
|
|
|
+ attr = ' target="_blank"';
|
|
|
+ }
|
|
|
+ var html = '<tr><td width="90%"><input type="checkbox" checked name="'+name+'[]" value="'+ui.item[value]+'"/> '+pic+'<a href="'+link+'" '+attr+' title="'+ui.item.value+'">'+ui.item.value+'</td><td width="10%"><a href="javascript:;" onclick="autocomplete_del($(this), \''+id+'\', \''+ui.item[value]+'\')">[删除]</a></td></tr>';
|
|
|
+ $("#" + id + '_show').append(html);
|
|
|
+
|
|
|
+ autocomplete_value.push(ui.item[value]);
|
|
|
+ }
|
|
|
+
|
|
|
+ ui.item.value = '';
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function autocomplete_del(e, id, value)
|
|
|
+{
|
|
|
+ e.parent().parent().remove();
|
|
|
+ autocomplete_value.remove(value);
|
|
|
+}
|
|
|
+
|
|
|
//后台通用的提示
|
|
|
function msg(value)
|
|
|
{
|