原文发布时间为:2011-06-01 —— 来源于本人的百度文章 [由搬家工具导入]
@MyHelper.Script("jquery-1.6.1.min.js", Url)
@MyHelper.Script("jquery-ui-1.8.13.min.js", Url)
@MyHelper.Script("jquery.ui.datepicker-zh-CN.js", Url)
@MyHelper.Script("Test.js", Url)
@MyHelper.Script("jquery.tmpl.min.js",Url)
====================
<input type="text" data-autocomplete="@Url.Action("Auto", "Ajax")" data-default="Hello" value="Hello"/>
<input type="text" data-autocomplete="@Url.Action("Auto", "Ajax")" />
<input type="text" data-autocomplete="@Url.Action("Auto", "Ajax")" />
<input type="text" data-datepicker="true" />
<table>
<thead>
<tr>
<th>
Age
</th>
<th>
Name
</th>
</tr>
</thead>
<tbody id="list">
</tbody>
</table>
<script type="text/x-jquery-tmpl" data-tmpl="@Url.Action("Auto", "Ajax")" data-target="#list">
<tr><td>
${Age}
</td><td>
${Name}
</td></tr>
</script>
====================Test.js======================
/// <reference path="jquery-1.6.1-vsdoc.js" />
/// <reference path="jquery-ui-1.8.13.min.js" />
/// <reference path="jquery.tmpl.min.js" />
///http://www.asp.net/ajaxlibrary/cdn.ashx
///http://jqueryui.com/
///http://api.jquery.com/category/plugins/templates/
///http://bassistance.de/jquery-plugins/jquery-plugin-validation/
$(function () {
$("input[data-autocomplete]").each(function () {
$(this).focus(function () {
if ($.trim($(this).val()) == $(this).attr("data-default")) {
$(this).val("");
}
});
$(this).autocomplete({
source: $(this).attr("data-autocomplete"),
select: function (event, ui) {
$(this).val(ui.item.Name);
return false;
}
})
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.Age + "<br>" + item.Name + "</a>")
.appendTo(ul);
};
});
$("input[data-datepicker]").each(function () {
$(this).datepicker($.datepicker.regional["zh-CN"]);
});
$("script[data-tmpl]").each(function () {
var tmpl = $(this);
$.getJSON(tmpl.attr("data-tmpl"), function (data) {
$(tmpl.attr("data-target")).empty().append(tmpl.tmpl(data));
});
});
});