Link declared in a template, error when firing click event

2 posts, 0 answers
  1. T
    T avatar
    1 posts
    Member since:
    Aug 2014

    Posted 06 Sep 2014 Link to this post

    Hi,

    I have a Link declared in a template as shown in the code below. When I click on a link in the listview I get the error: "Uncaught TypeError: Object [object Object] has no method 'apply' "

    Thanks in advance.

    html:
    <div data-role="view" id="componentOverview" data-title="Component Overview" data-model="APP.componentOverview.model" data-init="APP.componentOverview.events.init" data-after-show="APP.componentOverview.events.afterShow">
        <h1>Component Overview</h1>
        <ul data-role="listview" data-style="inset" data-bind="source:components" data-template="componentsTemplate"></ul>
    </div>
     
    <script type="text/x-kendo-template" id="componentsTemplate">
        <a data-bind="click: onComponentSelect">#: title#</a>
    </script>

    js:
    define([
        'view/view',
        'text!view/componentOverview/componentOverview.html',
        'app'
    ], function (View, html, app) {
     
        var model = kendo.observable({
            components: app.data.components,
            onComponentSelect: function(e) {
                var compId = e.data.id;
                app.instance.navigate('componentDetail?id=' + compId);
            }
        });
     
        var events = {
            init: function (e) {
            },
            show: function (e) {
            },
            afterShow: function (e) {
            }
        };
     
     
        return new View('componentOverview', html, model, events);
    });
  2. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 10 Sep 2014 Link to this post

    Hello,

    the view definition does not seem familiar to me, but I assume that this is your own abstraction. Based on the snippet, I prepared the following example, and it seems to work as expected. Perhaps I am missing something? 

    Regards,
    Petyo
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top