BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
<SfSidebar @ref="sidebar" ID="sidebar" Width="250px" MediaQuery="(min-width: 600px)" OnOpen="open">
<ChildContent>
<SfButton @onclick="Close" CssClass="e-btn close-btn">Toogle Sidebar</SfButton>
<div style="text-align: center;" class="text-content"> Sidebar </div>
</ChildContent>
</SfSidebar>
<div class="text-content" style="text-align: center;">
<SfButton @onclick="Close" CssClass="e-btn close-btn">Toogle Sidebar</SfButton>
Main content
</div>
@code {
[Inject]
public IJSRuntime JSRuntime { get; set; }
SfSidebar sidebar;
public void Close()
{
this.sidebar.Toggle();
}
public void open()
{
JSRuntime.InvokeAsync<int>("Sidebar");
}
}
<script>
function Sidebar() {
var sidebar = document.getElementById("sidebar").ej2_instances[0];
if (!window.matchMedia("(min-width: 600px)").matches) {
sidebar.type = "Over";
}
else {
sidebar.type = "Push";
}
}
</script> |
Hi,
It appears that the above javascript no longer works in the latest version.
When i declare "var sidebar = document.getElementById("sidebar").ej2_instances[0]; " it does not have a property called type.
But when it is set it does nothing anyway when media is less than 600px. It sets .type as "Over" but it makes no difference.
Is there an updated version of this.
Thanks
Fergus
[MainLayout.razor] <SfMediaQuery @bind-ActiveBreakpoint="@activeBreakpoint"></SfMediaQuery> ..... @*Initialize the Sidebar component*@ <SfSidebar @attributes="@HtmlAttribute" Width="290px" @bind-Type="@sidebarType" Target=".e-main-content" @bind-IsOpen="SidebarToggle" OnOpen="Opened"> ....... </sfSidebar> @Code{ private string activeBreakpoint; public SidebarType sidebarType; public async Task Opened() { if (activeBreakpoint == "Small") { sidebarType = SidebarType.Push; } else if (activeBreakpoint == "Medium") { sidebarType = SidebarType.Slide; } else { sidebarType = SidebarType.Over; } } protected override void OnInitialized() { base.OnInitialized(); ....... SfMediaQuery.Small.MediaQuery = "(max-width: 600px)"; SfMediaQuery.Medium.MediaQuery = "(min-width: 600px)"; SfMediaQuery.Large.MediaQuery = "(min-width: 1100px)"; } } |