I'm trying to figure out how to embed a function in a template with 3+ levels of nested quotes. It works in one case, but not in another.
Here is the JSFiddle: http://jsfiddle.net/ZpCAy/62/
Here is the code:
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema: {
model: {
id: "OrderID"
}
}
},
columns: ["OrderID",
{ title: "Edit1", template:"<a href='javascript:(function(){window.open(\"www.oracle.com\");})();'>Edit1</a>" },
{ title: "Edit2", template:"<a href='javascript:(function(){$(\"#win\").kendoWindow();})();'>Edit2</a>" }
]
});
(Note that it won't actually run because of the Edit2 line. But if you remove that, the Edit1 will work)
When I run this in Chrome, I get this:
Uncaught Error: Invalid template:'<tr data-id="#=this.tmpl0(data)#"><td>${OrderID}</td><td><a href='javascript:(function(){window.open("www.oracle.com");})();'>Edit1</a></td><td><a href='javascript:(function(){$("#win").kendoWindow();})();'>Edit2</a></td></tr>' Generated code:'var o,e=kendo.htmlEncode;with(data){o='<tr data-id="'+(this.tmpl0(data))+'"><td>'+(e(OrderID))+'</td><td><a href=\'javascript:(function(){window.open("www.oracle.com");})();\'>Edit1</a></td><td><a href=\'javascript:(function(){$("';win").kendoWindow();})();'>Edit2</a></td></tr>;o+=;}return o;'
As you can see, the generated code is doing something to the "#win" and converting it to "';win" ... anyone know what's up?
Here is the JSFiddle: http://jsfiddle.net/ZpCAy/62/
Here is the code:
$("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema: {
model: {
id: "OrderID"
}
}
},
columns: ["OrderID",
{ title: "Edit1", template:"<a href='javascript:(function(){window.open(\"www.oracle.com\");})();'>Edit1</a>" },
{ title: "Edit2", template:"<a href='javascript:(function(){$(\"#win\").kendoWindow();})();'>Edit2</a>" }
]
});
(Note that it won't actually run because of the Edit2 line. But if you remove that, the Edit1 will work)
When I run this in Chrome, I get this:
Uncaught Error: Invalid template:'<tr data-id="#=this.tmpl0(data)#"><td>${OrderID}</td><td><a href='javascript:(function(){window.open("www.oracle.com");})();'>Edit1</a></td><td><a href='javascript:(function(){$("#win").kendoWindow();})();'>Edit2</a></td></tr>' Generated code:'var o,e=kendo.htmlEncode;with(data){o='<tr data-id="'+(this.tmpl0(data))+'"><td>'+(e(OrderID))+'</td><td><a href=\'javascript:(function(){window.open("www.oracle.com");})();\'>Edit1</a></td><td><a href=\'javascript:(function(){$("';win").kendoWindow();})();'>Edit2</a></td></tr>;o+=;}return o;'
As you can see, the generated code is doing something to the "#win" and converting it to "';win" ... anyone know what's up?