我正在使用app.Now中的对话框特性使用插件,每次单击按钮时,对话框中显示的数据都是从server.So请求的,它应该请求服务器并显示接收到的数据。
feed.hbs
{{#each feedResult as |feed|}}
<p {{action "toggleModal" feed.fivers_pk }}> {{feed.numFives}} </p>
{{#if isShowingModal}}
{{#modal-dialog close="toggleModal"}}
<p>People who Hi-Fived this</p>
<img src = "images/shape-line-separator.png">
Data from server
{{/modal-dialog}}
{{/if}}
{{/each}Controller.js(feed.js)
import Ember from 'ember';
import raw from 'ic-ajax';
const { service } = Ember.inject;
export default Ember.Controller.extend({
session:service('session'),
isShowingModal: false,
fivers:[],
feedResult:Ember.computed('model',function() {
SOME MANIPULATION WITH DATA
}),
actions:{
toggleModal: function(fiverpk) {
this.toggleProperty('isShowingModal');
console.log(fiverpk);
raw({
url: "http://example.com/api/photos/"+fiverpk+"/fivers/",
type: 'GET',
});
},
}
});我能够向服务器发出请求,并通过actions.But中的ajax调用接收数据,以及如何存储it.So,以便在打开时可以在模态对话框中使用它。
发布于 2015-12-30 13:15:41
您不需要处理AJAX请求返回的结果。你可以做如下的事情
raw({
url: "http://example.com/api/photos/"+fiverpk+"/fivers/",
type: 'GET',
}).then(function(result) {
// add the relevant part of the result to the modal
});https://stackoverflow.com/questions/34530191
复制相似问题