English 中文(简体)
我怎么能向信息清单上的顶点发出信息,而没有在铁路的废墟上填满一页?
原标题:How do I submit a message then add it to the top of a message list without page refresh in ruby on rails?

我有一个微观职位/主题系统,每次提交新的微观职位或评论/主题,以显示这一系统。

页: 1 我用:remote =>,在我的表格上设置了麻风机;现在,我真的想在不上页的复读的情况下提供微调或添加。

到目前为止,我已经:

class MicropostsController < ApplicationController

def create

    if params[:micropost][:user_id].to_i == current_user.id

     @comment = Comment.new(:user_id => current_user.id)
        respond_to do |format|
            if @micropost.save

            format.js   { render :post_on_wall }
            else
            format.js   { render :form_errors }

            end
        end
    else

如果表格在点击前将所有验证和用户实际类型都考虑在内,那么“如果”@micropost.save”就会是真实的,它将在我称之为“后_”的档案中执行 j。 如果“@micropost.save”将执行“form_errors”中的代码。

替代物 我补充说,在用户进入零点和点击站时,只检查小哨所。 罚款。

在“后墙”档案中,我有:

$( .microposts ).prepend( <%= j render("users/partials/microposts") %> );

The problem with this is it basically grabs all the microposts that are looped through in the file thats being rendered "users/partials/microposts" then places them above everything thats in the ".microposts" div. Even the actual form to post a micropost located at the top of the ".microposts" is pushed down below the contents that was just added to the page. In this case 10 spaces down as I m using pagination and have set per_page to 10.

这里是我的html结构。

<div class= cf  id= content >
    <div id= leftColumn >
    </div>
    <div class= microposts >
    </div>
    <div id= rightColumn >
  </div>
</div>

每个微型站及其相关评论都储存在一个称为“后座”。

我感到,我这样说是错误的。 档案中“用户/部/电站”指出,基本上有帮助在某个时间显示几个微型站的代码(10)。 这与Im试图做的事情完全不同(想象+无休止的滚动)。

我感觉到,我应如何处理这一问题,就是如何发现刚刚张贴的新职位。 它应被觉察为新的“后主人”类别,然后在发现后应加在“后主人”名单上,而不是取代上面的微观职位表。

我只想制造一个单独的干.,以容纳所有微小哨所,然后把这种干.放在微调的后面,这样,我就不得不对正在推下的形式感到担忧,因为这将拖到包含所有不动的缩影子的干.中,而这是我所期待的。

这仍然使我面临这样一个问题,即让刚刚上岗的这个职位在名单上增加。

无论如何,我真的喜欢一个榜样或一些有助于我执行这一特点的良好建议。

Thanks for your time Kind regards.

最佳回答

有了你目前的超文本/部分结构,这恰恰相反(替代了自那部分人造成的全部微观职位)。

$( .microposts ).html( <%= escape_javascript render("users/partials/microposts") %> );

但是,将来,有一门“电梯”部分,使微观定位成为可能,然后,你可以很容易地将微台站排在顶端。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签