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

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

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

    隨筆-167  評論-65  文章-0  trackbacks-0

    在做rails的無刷新的數據更新時,老是在replace 和 replace_html上出問題,當你遇到此問題時,不煩二者嘗試下看看,看了下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相當于  OuterHtml , replace_html相當于 InnerHtml,那么OuterHtml 和 InnerHtml有什么區別呢,大致解釋如下:

    innerHTML 設置或獲取位于對象起始和結束標簽內的 HTML
    outerHTML 設置或獲取對象及其內容的 HTML 形式
    innerText 設置或獲取位于對象起始和結束標簽內的文本
    outerText 設置(包括標簽)或獲取(不包括標簽)對象的文本

    innerText和outerText在獲取時是相同效果,但在設置時,innerText僅設置標簽內的文本,而outerText設置包括標簽在內的文本。

    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 閱讀(818) 評論(0)  編輯  收藏 所屬分類: Rails
    已訪問數:
    free counters
    主站蜘蛛池模板: eeuss影院www天堂免费| 豆国产96在线|亚洲| 久久国产免费一区| 久久亚洲高清观看| 国产精品免费AV片在线观看| 亚洲国产综合91精品麻豆| 特级无码毛片免费视频尤物| 78成人精品电影在线播放日韩精品电影一区亚洲| 丝瓜app免费下载网址进入ios | 免费无码又爽又刺激网站| 国产精品亚洲аv无码播放| 182tv免费视频在线观看| 精品亚洲成a人片在线观看少妇 | a级大片免费观看| 久久亚洲精品成人| 97在线观看永久免费视频| 一本色道久久88—综合亚洲精品| 暖暖在线日本免费中文| 四虎一区二区成人免费影院网址| 亚洲色偷拍另类无码专区| 一级毛片免费观看不卡视频| 亚洲AV综合色区无码二区爱AV| 在线看片人成视频免费无遮挡| 美女黄网站人色视频免费| 亚洲大尺度无码专区尤物| 亚洲免费视频网址| 国产亚洲精品91| 精品国产综合成人亚洲区| 成人黄色免费网站| 另类专区另类专区亚洲| 亚洲AV日韩AV永久无码下载| 成人午夜性A级毛片免费| 国产精品成人啪精品视频免费| 亚洲精品免费在线观看| 国产精品免费看久久久久| 国产午夜免费高清久久影院| 亚洲人成人网毛片在线播放| 亚洲日本韩国在线| 国产免费毛不卡片| 黄视频在线观看免费| 亚洲偷自精品三十六区|