Skip to content

Instantly share code, notes, and snippets.

@qichunren
Created February 28, 2011 07:15
Show Gist options
  • Save qichunren/847033 to your computer and use it in GitHub Desktop.
Save qichunren/847033 to your computer and use it in GitHub Desktop.
使用bbcode编辑器
<%= content_for :html_head do %>
<%= javascript_include_tag "jquery.bbcode.js" %>
<%= javascript_tag do %>
$(function(){
$("#web_message_content").bbcode({tag_bold:true,tag_italic:true,tag_underline:true,tag_link:true,tag_image:true,button_image:true,image_url:'/images/bbcode/'});
$("#bbcode_preview_btn").bind("click", function(){
var bbcode = $("#web_message_content").val();
$.get("/utils/parse_bbcode", {id:bbcode}, function(text){
$("#preview").html(text);
});
});
if(!$("#send_now").attr("checked")){
$("#send_now").click();
};
$("#send_now").click(function(){
if($(this).attr("checked")){
$("#p_will_receive_at").hide();
} else {
$("#p_will_receive_at").show();
}
});
});
<% end %>
# encoding: utf-8
class UtilsController < ApplicationController
def parse_bbcode
render :text => params[:id].bbcode_to_html
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment