imvkmark
8/29/2013 - 8:07 AM

mustache

mustache

<?php
    $tpl = <<<areaCombo
	{{^isAjax}}
	<input type="hidden" name="{{postname}}" id="{{id}}" value="{{default}}" {{extend}}>
	<a id="reset_{{id}}"  class="easyui-linkbutton" iconCls="icon-reload">重置</a>
	<span id="container_{{id}}">
	{{/isAjax}}
	{{# formatArea }}
    <input id="area_{{id}}{{key}}" value="{{default}}">
	{{/ formatArea }}
	<script>
	seajs.use(['utils', 'easyui', 'easyui-css'], function (utils) {
	{{# formatArea }}
		$('#area_{{id}}{{key}}').combobox({
		    data:{{{areas}}},
		    valueField:'areaId',
		    textField:'areaName',
		    onSelect: function(area){
		        {{# formatArea }}
	            $('#area_{{id}}{{key}}').combobox('destroy');
	            {{/ formatArea }}
		        utils.areaCombo('{{id}}', {action:'areaCombo',aPid:area.areaId, aPostName:'{{postname}}', aMid:{{moduleid}}});
	        }
		});
	{{/ formatArea }}
	});
	</script>
	{{^isAjax}}
	</span>
	<script>
	seajs.use(['utils', 'easyui', 'easyui-css'], function(utils){
		$('#reset_{{id}}').on('click', function(){
			utils.areaCombo('{{id}}', {action:'areaCombo',aPid:{{default}}, aPostName:'{{postname}}', aMid:{{moduleid}}});
		})
	});
	</script>
	{{/isAjax}}
areaCombo;
	$m   = new Mustache_Engine;
	return $m->render($tpl, array(
			'postname'   => $postname,
			'id'         => $id,
			'default'    => $default,
			'extend'     => $extend,
			'formatArea' => $formatArea,
			'isAjax'     => $isAjax,
			'moduleid'     => $moduleid,
			'current'    => $AREA[$authCity]['areaname'],
		)
	);
?>