0

When I test, $root is throwing an uncaught reference error. These are the files involved, let me know if you need more information. But I can't honestly see what I'm doing wrong.

Is there something I need to do to make $root available to me? Is it exclusive to mobile apps only?

shows.js

VelocityMeetings.shows = function (params) {

    var errorMessage = ko.observable("");

    var viewModel = {
        errorMessage: errorMessage,
        errorVisible: ko.computed(function() {
            return errorMessage().length != 0;
        }),
        hideError: function () {
            errorMessage("");
        },
        resultsItemClick: function () {
            alert('ok')
        }
    };

    return viewModel;
};

shows.dxview

<div data-options="dxView : { name: 'shows', title: 'Trade Shows' } ">
    <div style="font-size: 11px;" class="shows-view" data-options="dxContent : { targetPlaceholder: 'content' } ">


        <br />
        <img src="images/logo.jpg" />

        <div style="color: red; margin: 5px; font-size: 12px;" data-bind="visible: errorVisible, text: errorMessage"></div>

        <br />
        <div style="font-size: 14px; color: rgb(98, 31, 137); font-weight: bold;">My Shows</div>
        <br />

        <div data-bind="dxList: { dataSource: Shows }">
            <div data-options="dxTemplate: { name: 'item' }, dxAction: $root.resultsItemClick" style=" style =" border: 1px solid lightgrey; padding: 15px; color black; width: 200px; margin: auto;">
                <img data-bind="attr:{ src:  image }" /><br />
                <b><span data-bind="text: date"></span></b><br />
                <b><span data-bind="text: location"></span></b>
            </div>
         </div>

    </div>
</div>
War10ck
  • 12,387
  • 7
  • 41
  • 54
Cody Jones
  • 424
  • 1
  • 5
  • 16

1 Answers1

1

I was mixing up Data-options and data-bind attributes.

<div data-options="dxTemplate: { name: 'item' }" data-bind="dxAction: $root.resultsItemClick" style =" border: 1px solid lightgrey; padding: 15px; color black; width: 200px; margin: auto;">

Thats what the template line should be if anyone is struggling.

Cody Jones
  • 424
  • 1
  • 5
  • 16