1

私は Meteor の初心者で、フォームメーカー (mforms) を作ろうとしています: https://github.com/miguelalarcos/mforms

入力が日付ピッカーであることをいつ宣言する必要があるかについて質問があります。

$('.'+form_name+'_attr_date').datepicker(format: 'dd-mm-yyyy', autoclose:true)

より良い場所が Meteor.startup なのか、それとも template.rendered なのかはわかりません。先行入力テキストの関数ソースを宣言する場合も同様です。

前もって感謝します。

4

1 に答える 1

1

ユーザーがそのテンプレートを使用するときにのみ実行されるため、template.rendered 内に配置します。スタートアップに配置すると、すべてのユーザーに対して実行されます-そのユーザーがその日付ピッカーでテンプレートを使用していない場合でも。さらに、スタートアップ内のコードはサーバーとクライアントで実行されます。このコードをサーバーで実行しても意味がありません。

ドキュメントから:

レンダリング

This callback is called once when an instance of Template.myTemplate is rendered into DOM nodes and put into the document for the first time, and again each time any part of the template is re-rendered.

起動

Run code when a client or a server starts.

On a server, the function will run as soon as the server process is finished starting.
On a client, the function will run as soon as the DOM is ready.
于 2013-06-22T12:42:12.733 に答える