Created
June 19, 2012 07:35
-
-
Save jhjguxin/2952820 to your computer and use it in GitHub Desktop.
Kindeditor ajax post for Ruby on Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_form.html.erb | |
<%= f.input :body, :width => 850, :height => 500 %> | |
refresh.js.erb | |
$("#edit_<%= dom_id @knowledge %>").replaceWith("<%= render 'refresh_form'%>"); | |
$("#new_knowledge").replaceWith("<%= render 'refresh_form'%>"); | |
var editor = KindEditor.create( | |
'textarea[id="knowledge_body"]', | |
{ | |
width : '850px', | |
height: '500px', | |
uploadJson: '/kindeditor/upload', | |
fileManagerJson: '/kindeditor/filemanager' | |
} | |
); | |
$(document).ready(function(){ | |
var editor = KindEditor.create( | |
'textarea[id="knowledge_body"]', | |
{ | |
width : '850px', | |
height: '500px', | |
uploadJson: '/kindeditor/upload', | |
fileManagerJson: '/kindeditor/filemanager' | |
} | |
); | |
$("input").click(function(){ | |
editor.sync('knowledge_body'); | |
// 同步数据后可以直接取得textarea的value | |
body = document.getElementById('knowledge_body').value; // 原生API | |
$("#knowledge_body").val(body); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment