如何将参数从 underscore.js 页面传递到 backbone.js 导航 url 更改
how to pass parameter from underscore.js page to backbone.js navigate for url changes
我想传递两个名为 "data-idVendor" 的参数,"data-idService" 位于 search.html file.I 想将这些参数值发送到我的 Backbone 导航URL changes.How 将那些参数值传递给我 backbone.history.navigate.Please 帮助我解决这个问题。
/search.html
<div class="col-md-4 tour_1 serviceDetails" data-idVendor="<%=value.idVendor%>" data-idService="<%=value.idService%>">
</div>
<!-- eg: data-idVendor = 1, data-idService = 1 -->
/search.js
events: {
"click .serviceDetails": "openServiceDetail"
},
openServiceDetail: function (event) {
event.preventDefault();
var currentElement = $(event.currentTarget);
/*How to pass those two value to backbone.history.navigate */
/*In the place of '/1/1/xyz' I want to send the dynamic data ' data-idVendor/data-idService/xyz' */
Backbone.history.navigate('/1/1/xyz', {
"trigger": true,
replace: false
});
Backbone.history.loadUrl(Backbone.history.fragment);
}
试试这个,使用“+”
openServiceDetail: function (event) {
event.preventDefault();
//Get jQuery value from params
var data-idVendor = $(event.target).attr("data-idVendor");
var data-idService = $(event.target).attr("data-idService");
Backbone.history.navigate(data-idVendor + "/" + data-idService +"/xyz" ,
{
"trigger": true,
replace: false
});
我想传递两个名为 "data-idVendor" 的参数,"data-idService" 位于 search.html file.I 想将这些参数值发送到我的 Backbone 导航URL changes.How 将那些参数值传递给我 backbone.history.navigate.Please 帮助我解决这个问题。
/search.html
<div class="col-md-4 tour_1 serviceDetails" data-idVendor="<%=value.idVendor%>" data-idService="<%=value.idService%>">
</div>
<!-- eg: data-idVendor = 1, data-idService = 1 -->
/search.js
events: {
"click .serviceDetails": "openServiceDetail"
},
openServiceDetail: function (event) {
event.preventDefault();
var currentElement = $(event.currentTarget);
/*How to pass those two value to backbone.history.navigate */
/*In the place of '/1/1/xyz' I want to send the dynamic data ' data-idVendor/data-idService/xyz' */
Backbone.history.navigate('/1/1/xyz', {
"trigger": true,
replace: false
});
Backbone.history.loadUrl(Backbone.history.fragment);
}
试试这个,使用“+”
openServiceDetail: function (event) {
event.preventDefault();
//Get jQuery value from params
var data-idVendor = $(event.target).attr("data-idVendor");
var data-idService = $(event.target).attr("data-idService");
Backbone.history.navigate(data-idVendor + "/" + data-idService +"/xyz" ,
{
"trigger": true,
replace: false
});