in design,after online editing,return json url,callback not finish
This commit is contained in:
parent
1839269581
commit
c9e4d0f345
|
@ -6,6 +6,7 @@ function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
|||
editor.filename = tfilename;
|
||||
editor.getUrl = tgetUrl;
|
||||
editor.postUrl = tpostUrl;
|
||||
editor.nodeToBeChanged=""
|
||||
editor.width = toption['width'];
|
||||
editor.height = toption['height'];
|
||||
var html='';
|
||||
|
@ -27,7 +28,12 @@ function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
|||
});
|
||||
};
|
||||
editor.send = function(){
|
||||
$.post(editor.postUrl,{filename:editor.filename,context:html.children("textarea").val(),authenticity_token:$('meta[name=csrf-token]').attr('content')});
|
||||
callback_for_send = function(data){
|
||||
editor.postUrl = data;
|
||||
alert($(this).attr("path"));
|
||||
};
|
||||
$.post(editor.postUrl,{filename:editor.filename,context:html.children("textarea").val(),authenticity_token:$('meta[name=csrf-token]').attr('content')},callback_for_send,"json");
|
||||
|
||||
};
|
||||
editor.destroy = function(){
|
||||
html.remove();
|
||||
|
|
|
@ -30,18 +30,18 @@ class Admin::DesignsController < ApplicationController
|
|||
file_to_removed = files.find{ |obj|
|
||||
obj.file_filename == filename
|
||||
}
|
||||
type = file_to_removed._type
|
||||
type = file_to_removed._type
|
||||
new_file = ""
|
||||
Dir.mktmpdir('design_temp'){ |dir|
|
||||
temp_file = File.new(dir+'/'+filename,'w+')
|
||||
temp_file.write params[:context]
|
||||
replace_target = eval("@design.#{type.downcase.pluralize}")
|
||||
a = replace_target.build(:file => temp_file,:to_save=>true)
|
||||
debugger
|
||||
new_file = replace_target.build(:file => temp_file,:to_save=>true)
|
||||
file_to_removed.destroy
|
||||
@design.save
|
||||
debugger
|
||||
temp_file.close
|
||||
}
|
||||
}
|
||||
render :json => new_file.file.url
|
||||
|
||||
end
|
||||
|
||||
|
|
Reference in New Issue