Hello!
I’m trying to create Action Sheet.
My Code:
return {
methods: {
switchCurrency: function (code) {
var $ = this.$;
var self = this;
console.log(code);
},
selectCurrency: function () {
var $ = this.$;
var app = this.$app;
var self = this;
app.preloader.show();
app.request({
url: app.data.api.site + '/index.php?route=tazboapi/locals/list_currencies',
crossDomain: true,
method: "GET",
success: function (successCurrencies) {
app.preloader.hide();
var currenciesObj = JSON.parse(successCurrencies);
var currenciesList = [{text:"Выбор валюты", label: true}];
for (var i = 0; i < currenciesObj.currencies.length; i++) {
curObject = {
text:currenciesObj.currencies[i].title,
onClick:function () {
app.dialog.alert('Cancel clicked' + i);
}
};
currenciesList.push(curObject);
}
currenciesList.push({text:"Закрыть", color:'red', close:true});
// Select language
var currencies = app.actions.create({
buttons: currenciesList
});
currencies.open();
},
error: function (errorCurrencies) {
app.preloader.hide();
var dialog = app.dialog.create({
title: 'Ошибка',
text: 'Не удалось получить данные! Попробуйте снова или обратитесь в поддержку!',
buttons: [
{
text: 'OK',
}
]
}).open();
},
});
},
}
}
I am processing the line with this function:
{"event":"success","currencies":[{"title":"Euro","code":"EUR","symbol_left":"","symbol_right":"\u20ac"},{"title":"Pound Sterling","code":"GBP","symbol_left":"\u00a3","symbol_right":""},{"title":"US Dollar","code":"USD","symbol_left":"$","symbol_right":""},{"title":"\u0420\u0443\u0431\u043b\u044c","code":"RUB","symbol_left":"","symbol_right":"\u20bd"}]}
I successfully create buttons, but all functions onClick open i=4
How do I properly create onClick function with unique parameter for each button?
Thank you!