I'm having trouble loading the collection which defines the insertHtml text/value pairs using a datasource.
What I'd like to do is have the user choose a template to edit, and have the insertHtml load accordingly. Therefore I have global datasources for the templates and the insertHtml data, and the change event on the template selector triggers a read on the insertHtml datasource:
For some reason this won't work. I'm getting an error in kendo.all.min.js:8 "Uncaught TypeError: Cannot call method 'removeClass' of undefined " when it tries to read into the insertHtml datasource.
What I'd like to do is have the user choose a template to edit, and have the insertHtml load accordingly. Therefore I have global datasources for the templates and the insertHtml data, and the change event on the template selector triggers a read on the insertHtml datasource:
<script type=
"text/javascript"
>
var
templateSource =
new
kendo.data.DataSource({
schema: {
data:
"d"
,
model: {
id:
"title"
,
fields: {
title: { type:
"string"
},
value: { type:
"string"
},
type: { type:
"number"
}
}
}
},
transport: {
read: {
contentType:
"application/json; charset=utf-8"
,
type:
"POST"
,
url:
"http://localhost:23035/foo/bar"
},
parameterMap:
function
(data, operation) {
if
(operation ==
"read"
) {
return
JSON.stringify({ user_id: arg(
'foo'
) })
}
}
}
})
var
tokenSource =
new
kendo.data.DataSource({
schema: {
data:
"d"
},
transport: {
read: {
contentType:
"application/json; charset=utf-8"
,
type:
"POST"
,
url:
"http://localhost:23035/foo/rab"
},
parameterMap:
function
(data, operation) {
var
type = $(
'#templateSelector'
).data(
"kendoDropDownList"
).dataItem().type;
return
JSON.stringify({ email_template_type_id: type })
}
}
})
$(document).ready(
function
() {
$(
"#templateSelector"
).kendoDropDownList({
dataTextField:
"title"
,
dataValueField:
"value"
,
dataSource: templateSource,
change:
function
() {
var
value = $(
"#templateSelector"
).val();
var
editor = $(
"#editor"
).data(
"kendoEditor"
);
editor.value(value);
tokenSource.read();
}
});
$(
"#editor"
).kendoEditor({
tools: [
"insertHtml"
],
insertHtml: tokenSource.data()
});
})
</script>
For some reason this won't work. I'm getting an error in kendo.all.min.js:8 "Uncaught TypeError: Cannot call method 'removeClass' of undefined " when it tries to read into the insertHtml datasource.