Internet Explorerで見知らぬエラーが発生しています。form_for remoteがInternet Explorerで動作しない
私はremote => trueのform_forを持っています。
次に、createアクションが呼び出されると、関連するcreate.js.erbファイルがあります。
私がそれを提出したらIEブラウザは返されたcreate.js.erbファイルをダウンロードするように頼みます。
これは、フォームに画像をアップロードしようとしたときにのみ発生します。
問題の内容がわかりません。
フォームはFirefoxとChromeで動作します。
私は画像のアップロードにremotipartを使用しています(それが役立つかどうかわかりません)。
さらに、画像添付用にクリップを使用しています。
以下、view、controller、create.js.erbを投稿します。
ビュー:
<% form_for @post, :remote => true, :html => {:multipart => true} do |f| %>
<%= f.text_area :message, :value => "What's up?" %>
<div id="newPostBottom">
<div id="newPostBottomRight">
<div id="loading">
Sharing <%= image_tag('spinner.gif') %>
</div>
<%= f.submit "Share", :class => 'button' %>
</div>
<div id="newPostBottomLeft">
<%= f.label :channel, "Select Channel:" %><%= f.select :channel, channels, :prompt => "Choose..." %>
<div id="postImageUpload">
<%= image_tag('icons/camera.png', :id => 'postUploadImageIcon', :alt => 'Upload Image', :title => 'Upload Image') %>
</div>
<%= f.file_field :post_image %>
</div>
</div>
<% end %>
コントローラー:
def create
account = Account.getAccountById(session[:user])
@post = account.posts.build(params[:post])
payload = {
"account_id" => account.id,
"name" => account.name,
"message" => params[:post][:message],
"channel" => params[:post][:channel]
}
if @post.save
Pusher['front-post-feed-channel'].trigger('front-post-feed-create', payload)
else
render :nothing => true
end
rescue ActiveRecord::RecordNotFound
reset_session
end
がCreate.js.erb:
$("#post_message").val("What's up?");
$("#post_message").css({height: '30px'});
$("#newPostBottom").hide();
$("#postsHomeFeed").prepend("<%= escape_javascript(render(:partial => '/posts/new_post', :locals => {:post => @post})) %>");
$("#loading").hide();
$("#post_submit").show();
$("#post_channel").val('');
$("#post_post_image").val('');
if($(".noContent").length > 0) {
$(".noContent").remove();
}
任意の助けに感謝。
おかげで、
ブライアンremotipart_response
ブロックであなたのcreate.js.erb
ファイルの内容をラップ
IEでファイルの上限サイズがありますか?私はあなたが言ったことをやったが、私は今働くために小さいサイズの画像を得ることができるが、大きなものはそうではない。 – Brian
が動作するようになりました。あなたが提案したものといくつかのjavascriptコードを追加しなければならなかった – Brian
どのバージョンのGemを使用していますか?最近の1.0バージョンでは、周囲のブロックの必要性がなくなりましたが、古いバージョンではまだそれが必要でした。 –