i have simple page kendo tabstrip inside
<div id="main-view" class="k-content"> @(html.kendo().tabstrip() .name("main-view-tabstrip") .items(tabstrip => { tabstrip.add().text("my notices").loadcontentfrom("mynotices", "notice").selected(true); })) </div>
it loads content me on demand, querying noticecontroller
. noticecontroller
has mynotices
action return me partialview
.
public partialviewresult mynotices() { // put values viewdata return partialview(); }
the partialview itseld looks this:
<div style="margin: 20px; height: 700px;"> @(html.kendo().grid<noticeviewmodel>(model) .htmlattributes(new { @class = "fullscreen" }) .name("noticeslist") .columns(columns => { columns.bound(x => x.uniqueid).title("uniqueid"); columns.bound(x => x.formname).title("form"); columns.bound(x => x.revision).title("revision"); columns.bound(x => x.language).title("language"); columns.bound(x => x.status).title("status"); } ) .pageable() .scrollable() .sortable() .selectable() .toolbar( toolbar => toolbar.create().text("new") ) .editable( ed => ed.mode(grideditmode.popup) .templatename("noticecreate") .window(w => w.title("create notice") .name("createnoticewindow1") .htmlattributes(new { id = "createnoticewindow" }) .modal(true) ) .displaydeleteconfirmation(true) ) .resizable(resize => resize.columns(true)) .datasource(datasource => datasource.ajax() .pagesize(25) .serveroperation(true) .read("list", "notice") .create("noticecreate", "notice") .events(events => events.error("errorhandler")) .model(model => model.id(x => x.uniqueid)) )) </div> <script> function errorhandler(e) { if (e.errors) { var message = "errors:\n"; $.each(e.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { message += + "\n"; }); } }); alert(message); } } </script>
when run code receive js error, errorhandler
cannot found. can see have inside partialview
.
<script> function errorhandler(e) { if (e.errors) { var message = "errors:\n"; $.each(e.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { message += + "\n"; }); } }); alert(message); } } </script>
so question how use javascript inside partial view, when show inside tabstrip?
when remove .events(events => events.error("errorhandler"))
grid, work fine.
fixed issue, not why, when put java script block @ beginning starts work.
so if meet such issue put <script/>
block before declaring kendo.grid()
.
Comments
Post a Comment