使用小胡子从数组循环中获取html drowdrop值 [英] get html drowdrop value from loop of array using mustache
本文介绍了使用小胡子从数组循环中获取html drowdrop值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
html代码
{{#locationDetails}} < 选择 id = locationcity >
< 选项 已选择 = 已选择 value = > {{allCities}} < / option >
< / select > {{/ locationDetails}}
javascript
var LocationDetails = function(templateUrl,dataUrl){
$ .get(templateUrl,function(template){
$ .get(dataUrl,function(data){
var html = Moustache。 to_html(模板,数据);
$(' #locationDetails')。html(html);
});
});
}
in controller
var locationDetails = new
{
allCities = getAllCities
};
return Json(locationDetails,JsonRequestBehavior.AllowGet);
getAllCities的值为[0]:chennai,[1]:像那样的班加罗尔
i需要在选项标签
解决方案
.get(templateUrl,function(template){
.get(dataUrl,function(data){
var html = Moustache。 to_html(模板,数据);
(' #locationDetails')。html(html);
});
});
}
in controller
var locationDetails = new
{
allCities = getAllCities
};
return Json(locationDetails,JsonRequestBehavior.AllowGet);
getAllCities的值为[0]:chennai,[1]:像那样的班加罗尔
i需要在选项标签中获取数组的值
html code
{{#locationDetails}}<select id="locationcity" > <option selected="selected" value="">{{allCities}}</option> </select>{{/locationDetails}}
javascript
var LocationDetails = function (templateUrl, dataUrl) { $.get(templateUrl, function (template) { $.get(dataUrl, function (data) { var html = Mustache.to_html(template, data); $('#locationDetails').html(html); }); }); }
in controller
var locationDetails = new { allCities=getAllCities }; return Json(locationDetails,JsonRequestBehavior.AllowGet);
getAllCities has value of [0]:chennai,[1]:bangalore like that
i need to get value of arrays in option tag解决方案.get(templateUrl, function (template) {
.get(dataUrl, function (data) { var html = Mustache.to_html(template, data);
('#locationDetails').html(html); }); }); }
in controller
var locationDetails = new { allCities=getAllCities }; return Json(locationDetails,JsonRequestBehavior.AllowGet);
getAllCities has value of [0]:chennai,[1]:bangalore like that
i need to get value of arrays in option tag
这篇关于使用小胡子从数组循环中获取html drowdrop值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文