<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 閱讀(819) 評論(0)  編輯  收藏 所屬分類: Rails
    已訪問數:
    free counters
    主站蜘蛛池模板: 91网站免费观看| 亚洲成在人线av| 亚洲AV无码乱码在线观看代蜜桃| 国产区在线免费观看| 免费成人黄色大片| 欧亚一级毛片免费看| 免费观看大片毛片| 色偷偷亚洲男人天堂| 国产精品免费播放| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 亚洲娇小性xxxx| 在线观看AV片永久免费| 亚洲砖码砖专无区2023| 妞干网免费视频在线观看| 亚洲а∨精品天堂在线| 日韩免费观看一级毛片看看| 亚洲av成人一区二区三区在线播放| 18禁超污无遮挡无码免费网站国产| 亚洲 欧洲 日韩 综合在线| 成人黄页网站免费观看大全| 美女无遮挡免费视频网站| 亚洲精品动漫人成3d在线| 中文在线观看国语高清免费| 亚洲va国产va天堂va久久| 亚洲熟妇成人精品一区| 国产传媒在线观看视频免费观看 | 特级av毛片免费观看| 国产成人99久久亚洲综合精品| 91成人免费福利网站在线| 78成人精品电影在线播放日韩精品电影一区亚洲 | 免费看AV毛片一区二区三区| 精品一区二区三区无码免费直播| 中文字幕日韩亚洲| 69视频在线是免费观看| 亚洲色少妇熟女11p| 亚洲国产精品人人做人人爽| a级片在线免费看| 亚洲一卡2卡3卡4卡国产网站| 国产免费无遮挡精品视频| 成人爽a毛片免费| 亚洲综合中文字幕无线码|