Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did the same a few days ago and I got Bootstrap Modals working by doing the following. I don't know if it is a good way, but it does the job for me. I am pretty new to ember as well, so feel free to corret me.</p> <p>Since you didn't provided more code, change the following so it fits your needs.</p> <p>In your router, catch the <code>edit</code> action and render your Modal-Template into the template you want. This might look something like this. </p> <pre><code>App.UserRoute = Ember.Route.extend({ actions: { edit: function() { return this.render('editmodal', { into: 'user', outlet: 'md' }); }, close: function() { return this.render('nothing', { into: 'user', outlet: 'md' }); } } }); </code></pre> <p>On click on close, it renders <code>nothing</code> into the template (since you want to close it)</p> <p>Put the form data in your editmodal. Make it a Bootstrap Modal. I just crap-copied it in my draft, I think you got to fix it to make it work.</p> <pre><code>&lt;script type = "text/x-handlebars" id = "editmodal"&gt; &lt;div class="modal-dialog"&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-header"&gt; &lt;div class="input-group"&gt; &lt;div class="user-edit"&gt; &lt;h4&gt;New Agent&lt;/h5&gt; &lt;h5&gt;Agent Avatar&lt;/h5&gt; {{input value=avatarUrl}} &lt;h5&gt;User name&lt;/h5&gt; {{input value=name}} &lt;h5&gt;User email&lt;/h5&gt; {{input value=email}} &lt;h5&gt;User short bio&lt;/h5&gt; {{textarea value=bio}} &lt;/div&gt; &lt;button {{action "save"}}&gt; Save &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/script&gt; </code></pre> <p>And you will also need a view, which might look something like this:</p> <pre><code>App.EditmodalView = Ember.View.extend({ didInsertElement: function() { var view; this.$('.modal').modal('show'); view = this; return this.$('.modal').on("hidden.bs.modal", function(ev) { view.controller.send('close'); }); }, layoutName: 'modal_layout', actions: { close: function() { this.$('.modal').modal('hide'); } } }); </code></pre> <p>As you can see, we are refering to a layoutName in here. By doing this, you can reuse a layout. You can also let it be and put everything in one template, but I like it reusable. Your layout might look like this:</p> <pre><code>&lt;script type = "text/x-handlebars" id = "modal_layout"&gt; &lt;div class="modal fade" role="dialog"&gt;{{yield}}&lt;/div&gt; &lt;/script&gt; </code></pre> <p>In the same attempt, think about the <code>nothing</code> template, which gets rendered in the template as soon as you close your modal</p> <pre><code>&lt;script type = "text/x-handlebars" id = "nothing"&gt; &lt;/script&gt; </code></pre> <p>In your <code>User</code> template I just added a name to your outlet.</p> <pre><code>&lt;script type = "text/x-handlebars" id = "user"&gt; &lt;div class="user-profile"&gt; {{#if deleteMode}} &lt;div class="confirm-box"&gt; &lt;h5&gt;Really?&lt;/h5&gt; &lt;button {{action "confirmDelete"}}&gt; yes &lt;/button&gt; &lt;button {{action "cancelDelete"}}&gt; no &lt;/button&gt; &lt;/div&gt; {{/if}} &lt;button {{action "edit"}}&gt;Edit&lt;/button&gt; &lt;button {{action "delete"}}&gt;Delete&lt;/button&gt; &lt;img {{bind-attr src="avatarUrl"}} alt="User's avatar" /&gt; &lt;h2&gt;{{name}}&lt;/h2&gt; &lt;span&gt;{{email}}&lt;/span&gt; &lt;p&gt;{{bio}}&lt;/p&gt; &lt;span&gt;Created {{creationDate}}&lt;/span&gt; &lt;/div&gt; {{outlet md}} &lt;/script&gt; </code></pre> <p>What i didn't wrote here is to handle your save events in your Modal.</p> <p>I hope this helps you going. As a beginner myself I know how Ember can really be a hard task. BTW: I think i saw a nice thread about the same issue, when i find it i will post it here</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload