我有一個控制器:RJS錯誤:從軌道RJS響應[對象錯誤]在IE 8/Scriptaculous的
render :update do |page|
page.replace_html 'some_id', :partial => 'some_partial'
end
它工作正常在Firefox,但IE拋出「RJS錯誤:[對象錯誤]」
在生成的JavaScript來看,它看起來像這樣:
Element.update("some_id", "\u003Cselect id=\"some_other_id\" name=\"some_name[]\"\u003E\u003Coption value=\"-1\"\u003E\u0026lt; Default option \u0026gt;\u003C/option\u003E\n\u003Coption value=\"1\" selected=\"selected\"\u003E Some option \u003C/option\u003E\u003C/select\u003E\n");
但即使Element.update("some_id", "hello world")
嘗試在IE中失敗。
儘管用空字符串取代仍然有效。
展望Element.update功能:
update: function(element, content) {
element = $(element);
if (content && content.toElement) content = content.toElement();
if (Object.isElement(content)) return element.update().insert(content);
content = Object.toHTML(content);
element.innerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
}
似乎element.innerHTML = content.stripScripts();
造成了一些麻煩,拋出一個「未知的運行錯誤」不管我餵它,除了空字符串。
我知道,IE會抱怨,如果試圖把一個塊級元素放入一個內聯元素,但事實並非如此。
我在軌道上2.3.11,Scriptaculous的1.8.1和原型1.6.0.3
我完全迷失了方向 - 任何提示是值得歡迎的。
我已經嘗試過使用'page.replace',但是它會替換整個'some_id'標記而不僅僅是它的innerHTML。 但是'options_for_select'的想法就像魅力! :-) 'page.replace_html 'inner_id',options_for_select(收集,選擇)' 不知道爲什麼,必須是 「IE魔術失敗綜合症」 ... 謝謝! –
只是爲了澄清 - 使用'replace_html'更新選擇列表看起來像這樣:''替換當前選擇的選項與選擇標記及其選項。我想IE不喜歡這種標記,但其他瀏覽器更寬容。很高興看到你有它的工作。 – inkdeep