2

ユーザーがサインアップしたときにjQueryを呼び出すことが可能かどうかはわかりません。

RailsとDevisegemを使用しているので、after_sign_up_pathがあります。

  def after_sign_up_path_for(resource)
    edit_user_registration_path(current_user)
    //call jQuery 
 end

またはこれが不可能な場合-なぜ私のjsが機能しないのですか?

   if($('.alert').val()=='Welcome! You have signed up successfully.')) 
      $('#congrats').show();

編集:HTML

      <div class="alert alert-notice">Welcome! You have signed up successfully.</div>
4

1 に答える 1

2

)あなたのコードには余分なものがあります:

 if($('.alert').val()=='Welcome! You sign up.')) 
                                //  -----------^

これを試して:

if ( $('.alert').val() == 'Welcome! You sign up.' ) {
      $('#congrats').show();
}

div要素の場合、次text()の代わりに使用する必要がありますval()

if ( $('.alert').text() == 'Welcome! You have signed up successfully.' ) {
      $('#congrats').show();
}
于 2012-07-24T10:35:16.143 に答える