简体   繁体   English

Ember-bootstrap从javascript触发模式

[英]Ember-bootstrap to trigger modal from javascript

From the link here if you scroll down to the example with the button label 'Reopen Modal' They seem to be triggering the modal from javascript. 如果您向下滚动到带有标签“ Reopen Modal”的示例,则从这里的链接开始 ,它们似乎触发了javascript的模态。 I have tried Ember.$('.modal).modal('show') with no luck, and cant seem to figure out a way to trigger it from js. 我没有运气尝试过Ember.$('.modal).modal('show') ,似乎无法找出从js触发它的方法。

My goal is, after a user submits a form and it is successfully validated, the modal appears. 我的目标是,在用户提交表单并成功验证表单之后,将出现模式。

Template 模板

{{#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}}

Component 零件

import Ember from 'ember';

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

No. The modal would be shown by a boolean property. 否。模态将由布尔属性显示。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM