如何同步调用ember动作

时间:2015-07-17 13:28:40

标签: ember.js

我想同步执行几个ember动作,这是做什么的正确方法。例如

<?php
$query  = "SELECT * FROM `awards` ";
$query  .= "WHERE `active` = '1' ";
$query  .= "ORDER BY `date` DESC ";
$query  .= "LIMIT $idStart, 10 "; 
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$projectId = $row["id_project"]; //Set a variable here and use later
    $query2  = "SELECT * FROM `projects` ";
    $query2  .= "WHERE `id_fm` = '$projectId' AND `active` = '1' ";
    $result2 = mysql_query($query2); 
    while($row2 = mysql_fetch_array($result2)){
    if($projectId == "PRJ000"){
        $tempID = "#";
        $tempProjectName = "General";
    }
    else {
        $tempID = $row2["id_x"];
        $tempProjectName = $row2["title"];
    }
}
?>

或如何在不使用this.send('closeModal'); this.send('openModal','login'); // run when `closeModal` is totally executed

的情况下调用路线中的操作
send

1 个答案:

答案 0 :(得分:1)

也许您可以将动作逻辑移动到路线上的其他功能,即

export default Ember.Route.extend({
  openModal: function() {
    ...logic...
  },

  closeModal: function() {
    ...logic...
  },

  actions:{
    openModal: function () {
      this.closeModal(); // Ensure other modals are closed.
      this.openModal();
    });

    closeModal: function () {
      this.closeModal();
    });
  }
});