Search code examples
javascriptkendo-uiteleriktelerik-appbuilder

Drawer will not open from main page


I have been trying to follow along on the video here: http://www.telerik.com/videos/platform/building-mobile-apps-using-telerik-platform---part-i

According to the tutorial, from the todos page (which is the main page), when I click the drawer icon/button, then the drawer page should show up.

But, my drawer won't open - in Chrome debugger, I keep getting this error: "Uncaught TypeError: Cannot read property 'openFor' of undefined" when I click on the drawer icon. Any help?

I am using the in-browser client.

Samething is happening with the popup/modal for the new todo.

My code is below for the todos.html:

<div data-role="view" id="todos" data-model="APP.todos.model" data-init="APP.todos.events.init" data-after-show="APP.todos.events.afterShow">
  <header data-role="header">
     <div data-role="navbar">
        <a data-role="button" data-rel="drawer" href="#categories" data-icon="drawer-button" data-align="left"></a>
        <span data-role="view-title"></span>
        <a data-role="button" data-rel="modalview" href="#newTodo" data-align="right" data-icon="compose"></a>
     </div>
  </header>
  <ul data-role="listview" data-style="inset" data-bind="source: todos" data-template="todos-template" data-pull-to-refresh="true"></ul>
</div>
<script type="text/x-kendo-template" id="todos-template">
   #: title #<a class="todo-close" data-bind="click: removeTodo"><i class="fa fa-check-square-o fa-lg"></i></a>
</script>

Code for categories.html:

<div data-role="drawer" id="categories" style="width: 270px" data-model="APP.categories.model" data-before-show="APP.categories.events.beforeShow" data-views="['todos']" class="">
   <div class="km-group-title">Categories</div>
   <ul data-role="listview" data-bind="source: categories" data-template="categories-template"></ul>
   <a data-role="button" data-icon="compose" class="full" data-rel="modalview" href="#newCategory">New</a>
</div>

<script type="text/x-kendo-template" id="categories-template">
   <a data-bind="click: onCategorySelect">#: name #</a>
</script>

Solution

  • I found out what the problem was: the video tutorial did not mention this at all - that inside app.js - I need to include all new views within the require clause such as this:

    require([
                'views/todos/todos',
                'views/categories/categories',
                'views/newTodo/newTodo',
                'views/newCategory/newCategory'
            ]