YUI3 Uploader + Rails rjs
我正在尝试将YUI3 Uploader与Rails 2.3.12项目一起使用。 我已经完成了上传后解析响应的工作。 响应是一个RJS文件呈现部分,以更新页面上的元素。
当通过正常的非Flash上传运行时,此RJS按预期工作,并且它与SWFUpload插件一样正常工作。
在Firefox中,我收到错误:
Error: missing } after property list Source File: http://secure.symt.localhost:3000/training_videos/4/edit Line: 0, Column: 204 Source Code: try { __flash__toXML(YUI.applyTo("yui_3_4_0_2_1314649381592_1","SWF.eventHandler",["yuiswfyui_3_4_0_2_1314649381592_14",({data:"try {\nElement.replace(\"training_video_4_poster_current\", \"Current poster: logo with spaces.JPG — [delete this file]\");\nElement.replace(\"ajax-flash-container\", \"\n\n\n\t\n\t\t\n\n setDoMessages();\n\n\n\");\n} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.replace(\\"training_video_4_poster_current\\", \\" \n\t\nCurrent poster: logo with spaces.JPG — [delete this file]\\");\nElement.replace(\\"ajax-flash-container\\", \\"\\n\\n\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\t\\ti\\n\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t- File uploaded.
\\n\\t\\t\\t\\t
\\n\\t\\t\\t\\n\\t\\t\\t \\n\\t\\t\\n\\t\\n\\t\\n\\n\\n setDoMessages();\\n\\n\\n\\");'); throw e }",type:"uploadcompletedata",id:"file0"})])) ; } catch (e) { ""; }
Chrome给了我:
Uncaught SyntaxError: Unexpected token ILLEGAL
有任何想法吗?
解决了,有点。 我为这些操作放弃了RJS,而是编写了一个输出所需javascript的ERB模板。
与YUI Uploader的JS包装和转义相结合的RJS助手正在破坏事物 – 现在我只是正在渲染我需要的东西。