<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永久无码精品国产精品 | 一区二区免费国产在线观看| 免费a级毛片视频| 久久九九免费高清视频| 亚洲自偷自拍另类图片二区| 久久精品网站免费观看| 成人嫩草影院免费观看| 亚洲VA成无码人在线观看天堂| 日韩免费高清播放器| 亚洲国产成人精品电影| 天天摸夜夜摸成人免费视频| 一级白嫩美女毛片免费| 亚洲视频在线一区| 国产高清在线免费视频| 全黄大全大色全免费大片| 无码专区—VA亚洲V天堂| 九九精品免费视频| 亚洲日韩在线中文字幕综合| 亚洲国产一成久久精品国产成人综合 | 亚洲综合色婷婷七月丁香| 青青草无码免费一二三区| 亚洲人成影院午夜网站| 免费少妇a级毛片人成网| a级毛片视频免费观看| 一级特黄a大片免费| 一级女性全黄久久生活片免费| 亚洲影院天堂中文av色| 亚洲国产成人久久99精品| 亚洲男人的天堂在线va拉文| 日韩插啊免费视频在线观看| 国产亚洲午夜精品| 久久久国产精品亚洲一区| 亚洲人妻av伦理| 在线观看无码的免费网站| 久久精品毛片免费观看| 欧洲美女大片免费播放器视频| 亚洲综合色区中文字幕| 亚洲va国产va天堂va久久| 久久亚洲2019中文字幕| 日韩一级免费视频| 无码区日韩特区永久免费系列 |