我的项目有一个侧边菜单。我没有使用bootstrap模板。相反,为了学习目的,我正在开发自己的侧面菜单。
现在发生的事情就是显示和隐藏菜单,我正在使用jquery hide()
和show()
函数。
但这样做会使菜单在隐藏或显示时看起来很奇怪。
例如,您可以看到这个小提琴(延迟被故意设置为2s,以便您可以观察到奇怪的变化)。 https://jsfiddle.net/6v25oggm/3/
谁能帮助我呢?
答案 0 :(得分:4)
使用slideToggle
和一些简单的逻辑检查a
旁边是否有子菜单,可以大大减少您的代码。
请查看这个小提琴:https://jsfiddle.net/vxaoryg3/2/
答案 1 :(得分:2)
答案 2 :(得分:1)
使用 tigerdi 的建议& trichetriche 的解决方案(实施)
<强>更新强>
class CustomExpressionVisitor : DefaultExpressionVisitor
{
// Override method to mutate the query
}
class TestInterceptor : IDbCommandTreeInterceptor
{
public void TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
{
if (interceptionContext.Result.DataSpace == DataSpace.CSpace)
{
// We only process query command trees
// (there can be others such as insert, update or delete
var queryCommand = interceptionContext.Result as DbQueryCommandTree;
if (queryCommand != null)
{
// A bit of logging to see the original tree
Console.WriteLine(queryCommand.DataSpace);
Console.WriteLine(queryCommand);
// We call the accept method on the command expression with our new visitor.
// This method will return our new command expression with the changes the
// visitor has made to it
var newQuery = queryCommand.Query.Accept(new CustomExpressionVisitor());
// We create a new command with our new command expression and tell
// EF to use it as the result of the query
interceptionContext.Result = new DbQueryCommandTree
(
queryCommand.MetadataWorkspace,
queryCommand.DataSpace,
newQuery
);
// A bit of logging to see the new command tree
Console.WriteLine(interceptionContext.Result);
}
}
}
}
// In code before using any EF context.
// Interceptors are registered globally.
DbInterception.Add(new TestInterceptor());