weixin_39668282
weixin_39668282
2020-11-29 02:30

Toggle menuitems

feat(js): adds param to menuitem to toggle other menu items

fixes #8158

BREAKING CHANGE: Toggleable menu items are no longer registered with elgg.ui.registerTogglableMenuItems. Use a 'toggle' attribute when registering menu items.

feat(js): added a hook trigger to toggling of menu items

fixes #9697

该提问来源于开源项目:Elgg/Elgg

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

10条回答

  • weixin_39668282 weixin_39668282 5月前

    LOL i really like this PR... looking at some of my crappy code for toggling menu items and doing some stuff when a menu item toggles... this helps so much... hope you agree ;)

    点赞 评论 复制链接分享
  • weixin_39889597 weixin_39889597 5月前

    See this: https://github.com/hypeJunction/Elgg-ui_element_states/blob/master/README.md That's the direction I had in mind. I still don't like having two items in the markup.

    点赞 评论 复制链接分享
  • weixin_39638057 weixin_39638057 5月前

    Agree this is better than what we have, but it seems like it doesn't need any integration into the menu system:

     php
    ElggMenuItem::factory(array(
        ...
        'data-menu-toggle' => 'unfeature',
        'deps' => 'elgg/menu-toggle',
    ));
    
    点赞 评论 复制链接分享
  • weixin_39668282 weixin_39668282 5月前

    Agree this is better than what we have, but it seems like it doesn't need any integration into the menu system:

    why not help people? your proposal will have people wondering why a toggle sometimes works and sometimes not... reason: because they forgot the dependency and another toggle menu item registers it for them... but not in all cases...

    点赞 评论 复制链接分享
  • weixin_39668282 weixin_39668282 5月前

    same as the lightbox experience

    点赞 评论 复制链接分享
  • weixin_39638057 weixin_39638057 5月前

    can you make a PR for the simplest version of the states model so we can compare?

    On this, meeting halfway would be to have core UI code sniff DOM for [data-menu-toggle] and auto-require its module. Then at least the menu API doesn't have to learn about this component.

    I want to go on record as against helping people :) Well, really 1) sometimes more boilerplate is worth it if it helps devs understand the mechanism, and 2) it feels dirty to start teaching a menu system about client-side behavior modules; I'd rather it stay real dumb.

    点赞 评论 复制链接分享
  • weixin_39638057 weixin_39638057 5月前

    core UI code sniff DOM for [data-menu-toggle] and auto-require its module

    That doesn't help ajax-delivered markup though :(

    点赞 评论 复制链接分享
  • weixin_39668282 weixin_39668282 5月前

    That doesn't help ajax-delivered markup though :(

    thats why i added the hook

    点赞 评论 复制链接分享
  • weixin_39889597 weixin_39889597 5月前

    I will put together something simplistic.

    点赞 评论 复制链接分享
  • weixin_39668282 weixin_39668282 5月前

    replaced by #11240

    点赞 评论 复制链接分享

相关推荐