<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-167  評(píng)論-65  文章-0  trackbacks-0

    在做rails的無刷新的數(shù)據(jù)更新時(shí),老是在replace 和 replace_html上出問題,當(dāng)你遇到此問題時(shí),不煩二者嘗試下看看,看了下rails API

    replace(id, *options_for_render)

    Replaces the "outer HTML" (i.e., the entire element, not just its contents) of the DOM element with the given id.

    options_for_render may be either a string of HTML to insert, or a hash of options to be passed to ActionView::Base#render. For example:
      # Replace the DOM element having ID 'person-45' with the
      # 'person' partial for the appropriate object.
      page.replace 'person-45', :partial => 'person', :object => @person

    This allows the same partial that is used for the insert_html to be also used for the input to replace without resorting to the use of wrapper elements.

    Examples:
      <div id="people">
        <%= render :partial => 'person', :collection => @people %>
      </div>

      # Insert a new person
      #
      # Generates: new Insertion.Bottom({object: "Matz", partial: "person"}, "");
      page.insert_html :bottom, :partial => 'person', :object => @person

      # Replace an existing person

      # Generates: Element.replace("person_45", "-- Contents of partial --");
      page.replace 'person_45', :partial => 'person', :object => @person

    Source: show | on GitHub
    replace_html(id, *options_for_render)

    Replaces the inner HTML of the DOM element with the given id.

    options_for_render may be either a string of HTML to insert, or a hash of options to be passed to ActionView::Base#render. For example:
      # Replace the HTML of the DOM element having ID 'person-45' with the
      # 'person' partial for the appropriate object.
      # Generates:  Element.update("person-45", "-- Contents of 'person' partial --");
      page.replace_html 'person-45', :partial => 'person', :object => @person

    Source: show | on GitHub

    從api中可以看出replace相當(dāng)于  OuterHtml , replace_html相當(dāng)于 InnerHtml,那么OuterHtml 和 InnerHtml有什么區(qū)別呢,大致解釋如下:

    innerHTML 設(shè)置或獲取位于對(duì)象起始和結(jié)束標(biāo)簽內(nèi)的 HTML
    outerHTML 設(shè)置或獲取對(duì)象及其內(nèi)容的 HTML 形式
    innerText 設(shè)置或獲取位于對(duì)象起始和結(jié)束標(biāo)簽內(nèi)的文本
    outerText 設(shè)置(包括標(biāo)簽)或獲取(不包括標(biāo)簽)對(duì)象的文本

    innerText和outerText在獲取時(shí)是相同效果,但在設(shè)置時(shí),innerText僅設(shè)置標(biāo)簽內(nèi)的文本,而outerText設(shè)置包括標(biāo)簽在內(nèi)的文本。

    ref:

    http://www.cnblogs.com/zpq521/archive/2008/07/12/1241493.html

    http://blog.csdn.net/lynnlin1122/archive/2008/09/09/2905442.aspx

    http://www.87cool.com/articleShow.aspx?number=52

    write by feng
    posted on 2009-04-15 18:44 fl1429 閱讀(816) 評(píng)論(0)  編輯  收藏 所屬分類: Rails
    已訪問數(shù):
    free counters
    主站蜘蛛池模板: 免费鲁丝片一级在线观看| 91精品国产免费| 日韩a级毛片免费视频| 在线观看亚洲AV每日更新无码| 国产在线a免费观看| 亚洲熟伦熟女专区hd高清| 成人网站免费观看| 亚洲中文字幕无码久久| 最近2019中文字幕免费看最新| 亚洲中文字幕在线无码一区二区 | 亚洲欧洲久久av| 在线播放免费人成视频网站| 亚洲一区二区三区无码影院| 日韩在线视频播放免费视频完整版| 久久乐国产精品亚洲综合| 怡红院免费的全部视频| 亚洲综合一区二区国产精品| 51在线视频免费观看视频| 久久亚洲精品国产精品婷婷 | 久久免费观看视频| 无码专区—VA亚洲V天堂| 在线永久免费的视频草莓| 亚洲日韩中文字幕无码一区| 免费a级毛片无码av| 免费观看一区二区三区| 亚洲网红精品大秀在线观看| 毛片免费在线视频| 一级毛片a免费播放王色电影| 久热综合在线亚洲精品| 无码中文字幕av免费放| 人妻无码中文字幕免费视频蜜桃 | 亚洲国产成人精品久久 | 国产午夜成人免费看片无遮挡| 日韩精品一区二区亚洲AV观看| 成年人视频在线观看免费| 久久久久久久久久久免费精品| 亚洲白色白色永久观看| 国产免费人成视频在线观看| 免费毛片a线观看| 亚洲日本一线产区和二线| 亚洲欧洲国产精品香蕉网|