首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

用Rails3跟jQuery创建一个100% ajax CRUD应用

2012-12-23 
用Rails3和jQuery创建一个100% ajax CRUD应用% javascript_include_tag :defaults %% csrf_meta_tag

用Rails3和jQuery创建一个100% ajax CRUD应用

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>

to

<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' %>
<%= javascript_include_tag 'rails' %>

?

????? <%= content_tag :h1, yield(:title) if show_title? %>
????? <%= yield %>
??? </div>
? </body>

?

<div id="post_form"><%= render :partial => 'form' %></div>
<div id="posts_list"><%= render :partial => "posts" %></div>

? <p>
??? <%= f.label :title %><br />
??? <%= f.text_field :title %>
? </p>
? <p>
??? <%= f.label :content %><br />
??? <%= f.text_area :content, :rows => 5 %>
? </p>
? <p><%= f.submit %></p>
<% end %>


Ps1: That uses html5 to make our forms and links remotes (:remote => true), so it's not gonna work in any version of INTERNET EXPLORER yet.

Ps2: You can also use the redirect/render in your actions pointing to the index and then create only one javascript view (index.js.erb) treating that as you want. I prefer to keep things separated in case I decide to change the visual behavior of some view.

Ps3: Someone should make a generator for this ajax forms.

?

?

热点排行
Bad Request.