ember-bootstrap从JavaScript触发模态



如果您使用按钮标签'重新打开模态'向下滚动到示例,则它们似乎是从JavaScript触发了模态。我尝试过没有运气的Ember.$('.modal).modal('show'),似乎无法找到一种从JS触发它的方法。

我的目标是,在用户提交表单并被成功验证后,将出现模式。

模板

{{#bs-form model=register onSubmit=(action 'submit') novalidate=true as |form|}}
  {{form.element controlType="text" label="Username" placeholder="Username" property="username"}}
  {{form.element controlType="password" label="Password" placeholder="Password" property="password"}}
  {{bs-button defaultText="Submit" type="outline-success" buttonType="submit"}}
{{/bs-form}}
{{#bs-modal-simple open=modal1 title="Modal" renderInPlace=true}}
    This is a Modal.
{{/bs-modal-simple}}

组件

import Ember from 'ember';
export default Ember.Component.extend({
  actions: {
    submit() {
      Ember.$('.modal').modal('show');
    },
  },
});

no。模式将由布尔属性显示。

actions: {
    submit() {
      this.set('modal1', true);
    },
  },

最新更新