How to call showTab using JQuery in LightSwitch

耗尽温柔 提交于 2019-12-13 07:07:12

问题


Can anybody help in calling the screen.showTab("TabName") using the JQuery! I am using Visual Studio 2015 Community Edition.

The same event is getting triggered from the .lsms.cs file but not .htm file (Inside the Script tag)

The way I am calling the showTab method from .lsml.cs is,

$(screen).on('templateLoaded', function (path) {
        $('#tabOne').bind("click", function () {
                        screen.showTab("TabOne");
                    });
                });

回答1:


As covered in the following SO post, normally you would programmatically change the current tab on a LightSwitch screen by using the showTab method available from the LightSwitch screen object:

LightSwitch Tabbed screen in Browse template

This LightSwitch screen object is passed into most of the standard LightSwitch methods including the screen's created routine and any button execute methods.

However, if the LightSwitch screen object isn't available at the point you need to execute the showTab, you can still access the method by instantiating an ad hoc screen instance and then calling its showTab method as follows:

$("#tabOne").bind("click", function () {
    var screen = new msls.Screen();
    screen.showTab("TabOne");
});

The reason the ad hoc screen instance can be used is that the showTab method ultimately addresses the currently active LightSwitch screen.



来源:https://stackoverflow.com/questions/38242936/how-to-call-showtab-using-jquery-in-lightswitch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!