javascriptc#visual-studio-lightswitch

Lightswitch: Custom button doesn't call method


I'm trying to add a new custom button to a view in the Lightswitch HTML client. visual editor for lightswitch

In the custom code for that view, the 'execute' method for that button is defined as followed (using the right click context menu to generate the signature to ensure it's correct).

/// <reference path="~/GeneratedArtifacts/viewModel.js" />

myapp.OLTP_AddEditLRIDetailsSet.Details_postRender = function (element, contentItem) {
    $("[data-ls-tap='tap:{data.shell.okCommand.command}']").hide(); // Hide Ok Button
    $("[data-ls-tap='tap:{data.shell.cancelCommand.command}']").hide(); // Hide Cancel Button
};


myapp.OLTP_AddEditLRIDetailsSet.Test_Method_execute = function (screen) {
    console.log('execute');
};

The first method hides the default buttons, the second is the execution code for the button. When the button is clicked in the web client, the method does not get called, and instead of hitting it the screen loads continuously (shown below).

The AddEditLRIDetails view is called from the AddEditMainTable view. In the context of the program MainTable is effectively a parent of LRIDetails. The code for calling the view is as follows:

myapp.OLTP_AddEditMainTable.AddLRI_execute = function (screen) {
    myapp.showOLTP_AddEditLRIDetailsSet(null, {
        beforeShown: function (OLTP_AddEditLRIDetailsSet) {
            var newLRI = new myapp.LRIDetailsSet();
            newLRI.MainTable = screen.MainTable1;
            OLTP_AddEditLRIDetailsSet.LRIDetailsSet = newLRI;
        },
        afterClosed: function () {
            // Refreshes the content so that the filter queries are applied
            screen.OLTP_LRIDetailsSet.refresh();
            screen.OLTP_LRIDetailsSet.load();
        }
    });
};

enter image description here

How can I fix this continuous loading so that the button method is actually called?


Solution

  • In the end I re-created the view and it's parent view. Sunk ~20h into trying to fix it otherwise. My advice for working in Lightswitch would be don't be afraid to rip it out and redo it, you'll save time