Javascript 如何将请求发送到服务器以获取ember中my modal对话框的数据
我正在为我的应用程序中的对话框功能使用ember modal dialog插件。现在dialog中显示的数据是从服务器请求的。因此,每次我单击按钮时,它都应该请求服务器并显示收到的数据 feed.hbsJavascript 如何将请求发送到服务器以获取ember中my modal对话框的数据,javascript,ember.js,modal-dialog,Javascript,Ember.js,Modal Dialog,我正在为我的应用程序中的对话框功能使用ember modal dialog插件。现在dialog中显示的数据是从服务器请求的。因此,每次我单击按钮时,它都应该请求服务器并显示收到的数据 feed.hbs {{#each feedResult as |feed|}} <p {{action "toggleModal" feed.fivers_pk }}> {{feed.numFives}} </p> {{#if isShowingModal}} {{#
{{#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}
我可以向服务器发出请求,并通过ajax调用接收数据。但是我应该在哪里以及如何存储数据。这样,当它打开时,我可以在模式对话框中使用它 对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
});
这就是我不能做的。来自服务器的响应是一个对象数组。类似于[{id:1},{id:2},{id:3}]。现在我应该如何以及在哪里存储,以便在我的hbs中使用它
raw({
url: "http://example.com/api/photos/"+fiverpk+"/fivers/",
type: 'GET',
}).then(function(result) {
// add the relevant part of the result to the modal
});