make sm_controller show the error in the js
This commit is contained in:
parent
5bce2d1615
commit
e446dcaeb5
2 changed files with 9 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ class StatusMessagesController < ApplicationController
|
|||
public_flag.to_s.match(/(true)|(on)/) ? public_flag = true : public_flag = false
|
||||
params[:status_message][:public] = public_flag
|
||||
|
||||
@status_message = current_user.build_post(:status_message, params[:status_message])
|
||||
@status_message = current_user.build_post(:status_message, params[:status_message].merge!(:message => ''))
|
||||
aspects = current_user.aspects_from_ids(params[:aspect_ids])
|
||||
|
||||
if @status_message.save
|
||||
|
|
@ -59,7 +59,7 @@ class StatusMessagesController < ApplicationController
|
|||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.js { render :text => @status_message.errors.full_messages, :status => 406 }
|
||||
format.js { render :json =>{:errors => @status_message.errors.full_messages}, :status => 406 }
|
||||
format.html {redirect_to :back}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -59,8 +59,13 @@ var Stream = {
|
|||
Publisher.clear();
|
||||
});
|
||||
|
||||
$(".new_status_message").bind('ajax:failure', function(data, html, xhr) {
|
||||
Diaspora.widgets.alert.alert('Failed to post message!');
|
||||
$(".new_status_message").bind('ajax:failure', function(data, html , xhr) {
|
||||
json = $.parseJSON(html.response);
|
||||
if(json.errors.length != 0){
|
||||
Diaspora.widgets.alert.alert(json.errors);
|
||||
}else{
|
||||
Diaspora.widgets.alert.alert('Failed to post message!');
|
||||
}
|
||||
});
|
||||
|
||||
$(".new_comment").live('ajax:success', function(data, json, xhr) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue