ACMS.Dispatch.Edit._related=function(elm){$(".js-related_entry_autocomplete_word").autocomplete({source:function(req,resp){var url="string"==typeof ACMS.Config.offset?"/"+ACMS.Config.offset:"/";url+="ajax/edit/autocomplete.json";$.ajax({url:url,type:"GET",cache:true,dataType:"json",data:{keyword:req.term},success:function(o){resp(o)},error:function(xhr,ts,err){resp([""])}})},minLength:2,select:function(event,ui){if(ui.item){var $tpl=_.template($(".js-related_entry_autocomplete_tpl").html()),result=
$tpl(ui.item),selector="[name^=related][value="+ui.item.id+"]";if($(selector).length===0)$(result).prependTo(".js-related_entry_index");else alert(ACMS.i18n.related.message1);ACMS.Dispatch.fieldgroupSortable($(".js-related_entry_index"))}$(".js-related_entry_autocomplete_word").val("");return false}});$(".js-related_entry_index").on("click",".js-related_entry_remove",function(){var $item=$(this).closest(".js-related_entry_item");$item.remove();return true})};
