<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
    主站蜘蛛池模板: 日本一区二区三区日本免费| 亚洲色精品88色婷婷七月丁香| 四虎免费久久影院| 久久亚洲春色中文字幕久久久| 精品特级一级毛片免费观看| 在线精品一卡乱码免费| 亚洲国产精品无码久久久蜜芽| 无人视频免费观看免费视频| 天天干在线免费视频| 亚洲乱码日产精品BD在线观看| 免费国产午夜高清在线视频| 亚洲Av无码乱码在线观看性色| 国产精品亚洲AV三区| 免费h成人黄漫画嘿咻破解版| 18禁亚洲深夜福利人口| 亚洲成色在线影院| 精品无码免费专区毛片| 亚洲视频网站在线观看| 99免费观看视频| 亚洲欧洲国产精品你懂的| 国产大片免费网站不卡美女| 一二三四在线观看免费中文在线观看| 亚洲国产成人精品91久久久| 国产精品色拉拉免费看| a级毛片免费观看视频| 亚洲色无码一区二区三区| 成人毛片免费观看视频大全| 国产青草亚洲香蕉精品久久| 内射干少妇亚洲69XXX| 亚洲国产精品尤物YW在线观看| 国产桃色在线成免费视频| 亚洲人成网站在线在线观看| 日本不卡在线观看免费v| 7m凹凸精品分类大全免费| 激情五月亚洲色图| 四虎影视免费永久在线观看| 免费看污成人午夜网站| 日本在线免费播放| 激情五月亚洲色图| 亚洲宅男天堂a在线| 亚洲成A人片在线观看无码3D|