首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加更多指向meteor-accounts ui-bootstrap-3下拉菜单的链接

添加更多指向meteor-accounts ui-bootstrap-3下拉菜单的链接
EN

Stack Overflow用户
提问于 2014-01-18 20:31:39
回答 3查看 809关注 0票数 2

用户使用meteor-accounts-ui-bootstrap-3包登录站点后,由{{loginButtons}}创建的下拉列表显示两个按钮。

如何向下拉菜单添加更多按钮?

EN

回答 3

Stack Overflow用户

发布于 2014-01-18 22:37:38

您将需要自定义该包。它应该位于项目的packages/目录中。控制此下拉菜单的文件是login_buttons_dropdown.html

请注意,运行mrt update可能会影响对陨石包所做的更改。您可能希望将包文件夹重命名为类似于accounts-ui-bootstrap-3-custom/的名称,执行mrt remove accounts-ui-bootstrap-3,然后重命名为mrt add accounts-ui-bootstrap-3-custom

票数 2
EN

Stack Overflow用户

发布于 2014-12-30 14:02:21

当然可以在不编辑包文件的情况下进行添加,比如在运行时注入代码。假设您使用iron:router,您可以在每次页面呈现之前向客户端注入HTML代码:

代码语言:javascript
复制
var addExtraHTML = function() {
  var user = Meteor.user();
  //check if user is signed in and that desired HTML element does not already exists
  if (user && $('#idOfDesiredHTMLElement').length===0) {
    var newHTML = "<a href='#' class='btn btn-default btn-block' id='idOfDesiredHTMLElement'>Edit Account</a>";
    //Add desired HTML above the change password button
    $('#login-buttons-open-change-password').before(newHTML);
  }
  this.next();
};

Router.onBeforeAction(addExtraHTML); //Injects HTML every time before the page loads

确保给你添加的东西一个id,这样你就可以跟踪已经存在的东西了!

票数 0
EN

Stack Overflow用户

发布于 2015-09-07 15:43:56

自从上一个答案有效后,Meteor发生了变化。

我让它工作的方法是附加到accounts-ui包中的dropdown模板的onRender事件。

测试地点:METEOR@1.1.0.3 - accounts-ui-unstyled@1.1.7

代码语言:javascript
复制
Template._loginButtonsLoggedInDropdownActions.onRendered(function() {

  // Validate user exists and YOUR ELEMENT is not already in place
  if (Meteor.user() && $('#YOUR_ELEMENT').length === 0) {

    // Inject YOUR ELEMENT before the 'Change password' button
    $('#login-buttons-open-change-password').before('<div class="login-button" id="YOUR_ELEMENT">YOUR_ELEMENT</div>');

    // EXTRA: Attach an event to YOUR ELEMENT
    $('#login-buttons-open-account-page').on('click', function() {
      // Event Action...
    });
  }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21204134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档