I'm trying to do localization for the upload widget using the bindings of the mvvm approach.
<input type="text" id="upload_field" data-role='upload' data-localization='{"select": local_select}' />
with local_select being a parameter from my observable object.
var uploadModel = new kendo.data.ObservableObject({
local_select:"Izberi..."
});
which is turn bound - var kendoView = kendo.bind($("#portal_content"), uploadModel);
The expected result is to the input itself showing the content from the object model but it throws an error (undefined) and crashes everything after it.
If I try using the #= # approach it crashes yet again with saying it's an illegal token. Finally I wrote a string data-localization='{"select": "Izberi..."}' and it works. It also works if I use any directly accessible js variable. Since I haven't had any significant problems binding any other values to other widgets so far (ok, there have been problems but mostly typos on my side :) ).
Is there something I'm doing wrong or does kendo have problems binding these values? I did at first thought that you don't have mvvm bindings so I created an extended widget out of upload.
kendo.data.binders.widget.localization.select = kendo.data.Binder.extend({
init: function (widget, bindings, options) {
//call the base constructor
kendo.data.Binder.fn.init.call(this, widget.element[0], bindings, options);
},
refresh: function () {
var that = this,
value = that.bindings["localization-select"].get(); //get the value from the View-Model
$(that.element).data("kendoRcgUpload").localization.select(value); //update the widget
}
});
But that hasn't worked out either. So I'm currently at a loss what else I could do - And I need to bind the value from the model since I need my code clean as a whistle :)
<input type="text" id="upload_field" data-role='upload' data-localization='{"select": local_select}' />
with local_select being a parameter from my observable object.
var uploadModel = new kendo.data.ObservableObject({
local_select:"Izberi..."
});
which is turn bound - var kendoView = kendo.bind($("#portal_content"), uploadModel);
The expected result is to the input itself showing the content from the object model but it throws an error (undefined) and crashes everything after it.
If I try using the #= # approach it crashes yet again with saying it's an illegal token. Finally I wrote a string data-localization='{"select": "Izberi..."}' and it works. It also works if I use any directly accessible js variable. Since I haven't had any significant problems binding any other values to other widgets so far (ok, there have been problems but mostly typos on my side :) ).
Is there something I'm doing wrong or does kendo have problems binding these values? I did at first thought that you don't have mvvm bindings so I created an extended widget out of upload.
kendo.data.binders.widget.localization.select = kendo.data.Binder.extend({
init: function (widget, bindings, options) {
//call the base constructor
kendo.data.Binder.fn.init.call(this, widget.element[0], bindings, options);
},
refresh: function () {
var that = this,
value = that.bindings["localization-select"].get(); //get the value from the View-Model
$(that.element).data("kendoRcgUpload").localization.select(value); //update the widget
}
});
But that hasn't worked out either. So I'm currently at a loss what else I could do - And I need to bind the value from the model since I need my code clean as a whistle :)