<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的無(wú)刷新的數(shù)據(jù)更新時(shí),老是在replace 和 replace_html上出問(wèn)題,當(dāng)你遇到此問(wèn)題時(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)  編輯  收藏 所屬分類(lèi): Rails
    已訪問(wèn)數(shù):
    free counters
    主站蜘蛛池模板: 亚洲av无码专区亚洲av不卡| 羞羞视频免费网站在线看| 国产免费av片在线无码免费看| 午夜在线免费视频| 久久亚洲中文字幕精品有坂深雪| 一二三四免费观看在线电影 | 羞羞视频免费网站在线看| 78成人精品电影在线播放日韩精品电影一区亚洲| 99久久久国产精品免费无卡顿| 亚洲AV噜噜一区二区三区| 亚洲av午夜成人片精品网站| 成人毛片视频免费网站观看| 两个人看的www高清免费视频| 亚洲人成网站色在线观看| 久久精品国产亚洲7777| 国产情侣激情在线视频免费看| 七次郎成人免费线路视频| 亚洲精品白色在线发布| 国产成人亚洲精品91专区手机| 成人午夜免费福利视频| 国产A∨免费精品视频| 中文字幕亚洲男人的天堂网络| 国产国拍亚洲精品福利| 毛片免费vip会员在线看| 九九美女网站免费| 黄色免费在线网址| 亚洲男人天堂2018av| 亚洲成人在线网站| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 1000部啪啪未满十八勿入免费 | 韩国免费一级成人毛片| 今天免费中文字幕视频| 全部一级一级毛片免费看| 美女视频黄免费亚洲| 亚洲综合一区二区精品导航| 国产成人亚洲精品91专区手机| 国产高清在线免费视频| 韩国免费一级成人毛片| 最近高清中文字幕免费| 99久久国产精品免费一区二区| 污污视频网站免费观看|