JavaScript executes and works on MSVS but doesn't work when published

56 views Asked by At

I am working with Lightswitch, and i am using this javascript to hide some buttons based on current user permissions. I am following this tutorial from MSDN:

https://msdn.microsoft.com/en-us/library/ff852062.aspx

This is my page

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

myapp.Inicio.VisualizarAgenda_execute = function (screen) {
window.location = "../WebForms/Agenda.aspx";
};
myapp.Inicio.VisualizarCorridaExecutadaCompleta_execute = function (screen) {
// Write code here.
window.location = "../WebForms/CorridaExecutadaCorridaCompleta.aspx";
};

myapp.Inicio.ColetaMotoristaCorridas_execute = function (screen) {
window.location = "../WebForms/ColetaMotoristaCorrida.aspx";
};

myapp.Inicio.created = function (screen) {
//screen.getCanExecuteClientes().then(function success() {
//    screen.findContentItem("ShowBrowseClientes").isVisible = true;
//}, function error() {
//    screen.findContentItem("ShowBrowseClientes").isVisible = false;
//})

//screen.getCanExecuteMotoristas().then(function success() {
//    screen.findContentItem("ShowBrowseMotoristas").isVisible = true;
//}, function error() {
//    screen.findContentItem("ShowBrowseMotoristas").isVisible = false;
//})

//screen.getCanExecuteVeiculos().then(function success() {
//    screen.findContentItem("ShowBrowseVeiculoes").isVisible = true;
//}, function error() {
//    screen.findContentItem("ShowBrowseVeiculoes").isVisible = false;
//})

screen.getCanExecuteEnderecosCorrida().then(function success() {
    screen.findContentItem("ShowBrowseEnderecoCorridas").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseEnderecoCorridas").isVisible = false;
})

screen.getCanExecuteCorridas().then(function success() {
    screen.findContentItem("ShowBrowseRotas").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseRotas").isVisible = false;
})

screen.getCanExecuteCorridasAgendadas().then(function success() {
    screen.findContentItem("ShowBrowseProgramacoesRota").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseProgramacoesRota").isVisible = false;
})

screen.getCanExecuteCorridasExecutadas().then(function success() {
    screen.findContentItem("ShowBrowseCorridaEsporadicas").isVisible = true;
    screen.findContentItem("ShowBrowseCorridas").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseCorridaEsporadicas").isVisible = false;
    screen.findContentItem("ShowBrowseCorridas").isVisible = false;
})

screen.getIsMotoristaQuery().then(function success() {
    screen.findContentItem("Cadastros").isVisible = false;
    screen.findContentItem("Fechamento").isVisible = false;
    screen.findContentItem("Relatorios").isVisible = false;
    screen.findContentItem("Basicos").isVisible = false;
    //screen.findContentItem("ShowBrowseColetaMotoristaCorridas").isVisible = true;
}, function error() {
    screen.findContentItem("Cadastros").isVisible = true;
    screen.findContentItem("Fechamento").isVisible = true;
    screen.findContentItem("Relatorios").isVisible = true;
    screen.findContentItem("Basicos").isVisible = true;
    //screen.findContentItem("ShowBrowseColetaMotoristaCorridas").isVisible = false;
})

};

My problem is: When i am on Debug, it works perfect. When i deploy on my own computer, still works. When i deploy on my Windows Server hosted on IIS , nothing happens.

Tested with both browsers(Local inside the server, and local on my development computer, which is not on the same network as the server)

1

There are 1 answers

0
BR BHARDWAJ On

if you are using id of controls by coping it from rendered html then yes it may not work when you deploy it. you must use class selector in jquery to acheave this or find the real id of content item or you can use static id if you are using .net 4 and above.