
/**
 * 更新关联内容
 * @param {type} data_json	要改变的值
 * @param {type} inputname	要获取和要改变值的input元值ID名称
 * @param {type} isappend	是否自增，默认为否
 * @returns {undefined}
 */
function select_add_itme_list(data_json, inputname, isappend) {
	if (data_json.length < 1) {
		return false;
	}
	$('#nevigate_linkid_botton .select_input_itme_title').hide();
	var select_add_itme_li = '';
	var select_add_itme_id;
	var select_add_itme_title;
	var select_add_itme_id_array = new Array();
	var select_add_itme_title_array = new Array();
	for (var i = 0; i < data_json.length; i++) {
		if (data_json[i]['id'] && data_json[i]['title']) {
			select_add_itme_id = data_json[i]['id'];
			select_add_itme_title = decodeURI(data_json[i]['title']);
			select_add_itme_li += '<li class="select_itme_id" id="select_itme_id_' + select_add_itme_id + '" data-id="' + select_add_itme_id + '" title="' + select_add_itme_title + '"><span class="select_choice_remove" role="presentation" id="select_id_' + select_add_itme_id + '" data-id="' + select_add_itme_id + '" title="' + select_add_itme_title + '">×</span><span><i class="espcms_icon_fa espcms_icon_fa-angle-right" aria-hidden="true"></i>' + select_add_itme_title + '</span></li>';
			//生成数组数据
			select_add_itme_id_array.push(select_add_itme_id);
			select_add_itme_title_array.push(select_add_itme_title);
		}
	}
	if (isappend) {
		$('#nevigate_linkid_botton .select_input_itme_list_ul').append(select_add_itme_li);
	} else {
		$('#nevigate_linkid_botton .select_input_itme_list_ul').empty().append(select_add_itme_li);
	}
	$('#nevigate_linkid').val(select_add_itme_id_array);
	$('#nevigate_linkid_title').val(select_add_itme_title_array);
	//删除元素
	$('#nevigate_linkid_botton .select_choice_remove').unbind('click').bind('click', function () {
		var doc_id = $(this).attr('data-id');
		var doc_title = $(this).attr('title');
		var li_name = '#select_itme_id_' + doc_id;
		select_add_itme_id_array.remove(doc_id);
		select_add_itme_title_array.remove(doc_title);
		$('#nevigate_linkid').val(select_add_itme_id_array);
		$('#nevigate_linkid_title').val(select_add_itme_title_array);
		$(li_name).remove();
		if (select_add_itme_id_array.length === 0) {
			$('#nevigate_linkid_botton .select_input_itme_title').show();
		}
	});
}

//删除关联内容元素，用于内容修改的时候，删除相关联的信息
function del_select_remove() {
	$('#nevigate_linkid_botton .select_choice_remove').unbind('click').bind('click', function () {
		var doc_id = $(this).attr('data-id');
		var doc_title = $(this).attr('title');
		var li_name = '#select_itme_id_' + doc_id;
		//获取原数据
		var nevigate_linkid = $('#nevigate_linkid').val();
		var nevigate_linkid_title = $('#nevigate_linkid_title').val();
		var nevigate_linkid_array = nevigate_linkid.split(',');
		var nevigate_linkid_title_array = nevigate_linkid_title.split(',');
		//去掉相关数组
		nevigate_linkid_array.remove(doc_id);
		nevigate_linkid_title_array.remove(doc_title);

		$('#nevigate_linkid').val(nevigate_linkid_array);
		$('#nevigate_linkid_title').val(nevigate_linkid_title_array);
		$(li_name).remove();
		if (nevigate_linkid_array.length === 0) {
			$('#nevigate_linkid_botton .select_input_itme_title').show();
		}
	});
}
