2016-03-02 61 views
0

我用流星包「useraccounts」,這爲我提供了一個2種形式 - 「登錄」和「註冊」。流星useraccounts - 內部狀態

我想用這2種形式2個不同的情態動詞 - 一個用於註冊,另一個用於登錄。

當我使用{{> atForm}}我之間的「登錄」和「註冊」的狀態,但在開始時打開它始終是一個「登錄」狀態,無論我打開哪個模式。

因此,如果用戶打開「註冊」模態應該顯示「註冊」的形式。如果「登錄」模式 - 「登錄」形式」。

現在它總是‘在這兩種情況下,登錄’狀態

當我使用{{> atForm狀態=‘註冊’}}它禁用切換。國家之間我必須保持這個選項。

我怎麼能做到這一點?

回答

1

您可以實現只是一個模式兩種,註冊和登錄的模板。然後,你可以通過調用AccountsTemplates.setState(new_state)切換atForm狀態。

例如:

Template.accountsModal.events({ 
    'click #login': function(e) { 
    e.preventDefault(); 
    AccountsTemplates.setState('signIn'); 
    $('#accountsModal').modal(); 
    }, 
    'click #register': function(e) { 
    e.preventDefault(); 
    AccountsTemplates.setState('signUp'); 
    $('#accountsModal').modal(); 
    } 
}); 

<template name="accountsModal"> 
    <div class="modal fade" id="accountsModal" tabindex="-1" role="dialog"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span> 
      </button> 
      <h4 class="modal-title">Modal title</h4> 
     </div> 
     <div class="modal-body"> 
      {{> atForm}} 
     </div> 
     </div> 
    </div> 
    </div> 
</template> 
+0

我需要兩情態動詞,因爲他們應該表現不同,這取決於行動(登錄或註冊)。任何其他建議? –