Events do not fire in the templates

2 posts, 0 answers
  1. Semyon Akimov
    Semyon Akimov avatar
    13 posts
    Member since:
    Dec 2008

    Posted 18 Jan 2015 Link to this post

    I use VS extension for AppBuilder and try to do following:

    My View (report.html file) here:

    <div data-role="view" id="view-all-tasks" data-layout="default" class="activities-view" data-model="app.pointTasksService.viewModel">
        <ul id="point-tasks-listview" data-type="group" data-style="inset" data-role="listview"
       data-template="pointTaskTemplate" data-header-template="pointTaskHeaderTemplate"
       data-bind="source: pointTasksDataSource" data-fixed-headers="true"></ul>

    </div>

    <!-- Task group template -->
    <script type="text/x-kendo-template" id="pointTaskHeaderTemplate">
       <span style="color:blue">${value}</span>
    </script>

    <!-- Tasks ListView Template -->
    <script type="text/x-kendo-template" id="pointTaskTemplate">
       <button id="show-dls-btn" data-bind="events: { click: reportSelect }"> Тест </button>
       //here are items from DataSource (display correctly)
    </script>

    My ViewModel here:
    var app = app || {};

    app.PointTasks = (function () {
    'use strict'

    // pointTasks model
    var pointTasksViewModel = kendo.data.ObservableObject.extend({
       pointTasksDataSource: null,

    init: function () {
    var that = this,
    dataSource;

    kendo.data.ObservableObject.fn.init.apply(that, []);

    dataSource = new kendo.data.DataSource({
    schema: {
    model: {
    Id: 'Id',
    fields: {
       ///here contains fields
    }
    },
    transport: {
    read: function (options) {
    $.ajax({
    type: "GET",
    url: myServiceURI,
    dataType: "json",
    });
    }
    },

    group: "FormattedDate()",
    sort: { field: 'FormattedDate()', dir: 'desc' }
    });

    that.pointTasksDataSource = dataSource;

    },

    reportSelect: function () {
       alert('Thats work fine!'); 
    }

    });

    app.pointTasksService = {
    viewModel: new pointTasksViewModel(),
    logout: function () {
    app.helper.logout();
    }

    };

    }());

    When I click on button (id="show-dls-btn") in ListView the error appears:
    "Uncaught TypeError: undefined is not a function from 'http://local/simulator/kendo/js/kendo.mobile.min.js:12"

    P.S.: If I move button out of template, event fires and all works fine.
  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 20 Jan 2015 Link to this post

    Hello Semyon,

    Please check an updated working version of your code.

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top