问题
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