<legend id='yj6hR'><style id='yj6hR'><dir id='yj6hR'><q id='yj6hR'></q></dir></style></legend>
    <bdo id='yj6hR'></bdo><ul id='yj6hR'></ul>
<tfoot id='yj6hR'></tfoot>
  • <i id='yj6hR'><tr id='yj6hR'><dt id='yj6hR'><q id='yj6hR'><span id='yj6hR'><b id='yj6hR'><form id='yj6hR'><ins id='yj6hR'></ins><ul id='yj6hR'></ul><sub id='yj6hR'></sub></form><legend id='yj6hR'></legend><bdo id='yj6hR'><pre id='yj6hR'><center id='yj6hR'></center></pre></bdo></b><th id='yj6hR'></th></span></q></dt></tr></i><div id='yj6hR'><tfoot id='yj6hR'></tfoot><dl id='yj6hR'><fieldset id='yj6hR'></fieldset></dl></div>

      1. <small id='yj6hR'></small><noframes id='yj6hR'>

        Rails 3.1 Ajax 问题

        Rails 3.1 Ajax question(Rails 3.1 Ajax 问题)

      2. <i id='VQ9tC'><tr id='VQ9tC'><dt id='VQ9tC'><q id='VQ9tC'><span id='VQ9tC'><b id='VQ9tC'><form id='VQ9tC'><ins id='VQ9tC'></ins><ul id='VQ9tC'></ul><sub id='VQ9tC'></sub></form><legend id='VQ9tC'></legend><bdo id='VQ9tC'><pre id='VQ9tC'><center id='VQ9tC'></center></pre></bdo></b><th id='VQ9tC'></th></span></q></dt></tr></i><div id='VQ9tC'><tfoot id='VQ9tC'></tfoot><dl id='VQ9tC'><fieldset id='VQ9tC'></fieldset></dl></div>
        • <small id='VQ9tC'></small><noframes id='VQ9tC'>

            <legend id='VQ9tC'><style id='VQ9tC'><dir id='VQ9tC'><q id='VQ9tC'></q></dir></style></legend>
              <tfoot id='VQ9tC'></tfoot>

                  <bdo id='VQ9tC'></bdo><ul id='VQ9tC'></ul>
                    <tbody id='VQ9tC'></tbody>
                  本文介绍了Rails 3.1 Ajax 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个名为 post 的脚手架,它有一个标题和一个描述.在我的布局上,我有一个链接可以创建一个具有 :remote => true 的新帖子.当我单击该远程链接以更改 div 的内容以便创建新帖子时,我将如何做到这一点?

                  I have a scaffold called post which has a title and a description. On my layout I have a link to create a new post that has :remote => true. How would I make it when I click on that remote link to change the content of a div so that I can create a new post?

                  推荐答案

                  假设您将使用的操作名为 new.您应该在视图/帖子中创建一个名为 new.js.erb 的文件,该文件将在您远程发布表单时呈现.该文件必须包含将新帖子放入要填充的 div 的 javascript.例如,它可能包含

                  Let's suppose the action you will use is called new. You should create a file called new.js.erb into views/posts that will be rendered when you post remotely your form. That file must include the javascript that places the new post into the div you want to fill. As an example, it could contain

                  # new.js.erb
                  $('div#container').html("<p><%= escape_javascript(@post.title) %></p>").append("<p><%= escape_javascript(@post.content) %></p>"); 
                  

                  ajax 帖子完成并创建新帖子后,javascript 将立即执行.请记住以下内容:- 你必须包括 jQuery- 您必须在 posts_controller 中指定呈现 .js 格式的能力,例如

                  The javascript will be executed immediately after the ajax post is finished and the new post is created. Remember the following: - You have to include jQuery - You have to specify in posts_controller the ability to render .js format, something like

                  # posts_controller.erb
                  def create
                      @post = Post.new(params[:post])
                  
                      respond_to do |format|
                        if @post.save
                          format.html { redirect_to(@post, :notice => 'Post created via non AJAX.') }
                          format.js # the actual ajax call
                        else
                          format.html { render :action => "new" }
                        end
                      end
                  end
                  

                  这篇关于Rails 3.1 Ajax 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)

                  <small id='wplXN'></small><noframes id='wplXN'>

                    <bdo id='wplXN'></bdo><ul id='wplXN'></ul>
                    <tfoot id='wplXN'></tfoot>
                      • <legend id='wplXN'><style id='wplXN'><dir id='wplXN'><q id='wplXN'></q></dir></style></legend>

                          1. <i id='wplXN'><tr id='wplXN'><dt id='wplXN'><q id='wplXN'><span id='wplXN'><b id='wplXN'><form id='wplXN'><ins id='wplXN'></ins><ul id='wplXN'></ul><sub id='wplXN'></sub></form><legend id='wplXN'></legend><bdo id='wplXN'><pre id='wplXN'><center id='wplXN'></center></pre></bdo></b><th id='wplXN'></th></span></q></dt></tr></i><div id='wplXN'><tfoot id='wplXN'></tfoot><dl id='wplXN'><fieldset id='wplXN'></fieldset></dl></div>
                              <tbody id='wplXN'></tbody>