YUI3 Uploader + Rails rjs [英] YUI3 Uploader + Rails rjs

查看:83
本文介绍了YUI3 Uploader + Rails rjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将YUI3上传器用于Rails 2.3.12项目.我已经解决了上传后解析响应的问题.响应是呈现部分内容的RJS文件,以更新页面上的元素.

I'm trying to use the YUI3 Uploader with a Rails 2.3.12 project. I've got it working up to the point of parsing the response after uploading. The response is an RJS file rendering a partial, to update an element on the page.

通过正常的非Flash上​​传运行时,此RJS可以按预期工作,并且与SWFUpload插件一起按预期工作.

This RJS works as expected when run via normal non-flash uploads, and it works as expected with the SWFUpload plugin.

在Firefox中,出现错误:

In Firefox, I get the error:

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\", \"<div class=\\"current_file_name\\" id=\\"training_video_4_poster_current\\">Current poster: <a href=\\"https://symtools_development.s3.amazonaws.com/system/symt_development/training_videos/posters/4/original/logo with spaces.JPG?1314649390\\" target=\\"new\\">logo with spaces.JPG</a> &mdash; <a href=\\"#\\" onclick=\\"if (confirm('Are you sure?')) { new Ajax.Request('/attachments/delete/training_video/4/poster', {asynchronous:true, evalScripts:true, method:'delete', parameters:'authenticity_token=' + encodeURIComponent('zzoL7fhstIy16isJGUdNQJ7ab4TNN+lMlOfJcBVabfo=')}); }; return false;\\">[delete this file]</a></div>\");\nElement.replace(\"ajax-flash-container\", \"\n<div id='ajax-flash-container' style='display:none'>\n\n\t\n\t\t<div id='info-message-container'>\n\t\t<div class=\\"flash info\\">\n\t\t\t<div class=\\"info-icon\\">i</div>\n\t\t\t<div class=\\"message-contents\\">\n\t\t\t\t<ul>\n\t\t\t\t\t<li>File uploaded.</li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t\t<div class=\\"clear\\">&nbsp;</div>\n\t\t</div>\n\t</div>\n\t\n</div>\n<script type='text/javascript'>\n  setDoMessages();\n</script>\n\n\");\n} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.replace(\\"training_video_4_poster_current\\", \\"<div class=\\\\"current_file_name\\\\" id=\\\\"training_video_4_poster_current\\\\">Current poster: <a href=\\\\"https://symtools_development.s3.amazonaws.com/system/symt_development/training_videos/posters/4/original/logo with spaces.JPG?1314649390\\\\" target=\\\\"new\\\\">logo with spaces.JPG</a> &mdash; <a href=\\\\"#\\\\" onclick=\\\\"if (confirm(\'Are you sure?\')) { new Ajax.Request(\'/attachments/delete/training_video/4/poster\', {asynchronous:true, evalScripts:true, method:\'delete\', parameters:\'authenticity_token=\' + encodeURIComponent(\'zzoL7fhstIy16isJGUdNQJ7ab4TNN+lMlOfJcBVabfo=\')}); }; return false;\\\\">[delete this file]</a></div>\\");\nElement.replace(\\"ajax-flash-container\\", \\"\\n<div id=\'ajax-flash-container\' style=\'display:none\'>\\n\\n\\t\\n\\t\\t<div id=\'info-message-container\'>\\n\\t\\t<div class=\\\\"flash info\\\\">\\n\\t\\t\\t<div class=\\\\"info-icon\\\\">i</div>\\n\\t\\t\\t<div class=\\\\"message-contents\\\\">\\n\\t\\t\\t\\t<ul>\\n\\t\\t\\t\\t\\t<li>File uploaded.</li>\\n\\t\\t\\t\\t</ul>\\n\\t\\t\\t</div>\\n\\t\\t\\t<div class=\\\\"clear\\\\">&nbsp;</div>\\n\\t\\t</div>\\n\\t</div>\\n\\t\\n</div>\\n<script type=\'text/javascript\'>\\n  setDoMessages();\\n</script>\\n\\n\\");'); throw e }",type:"uploadcompletedata",id:"file0"})])) ; } catch (e) { "<undefined/>"; }

Chrome给了我:

Chrome gives me:

Uncaught SyntaxError: Unexpected token ILLEGAL

有什么想法吗?

推荐答案

已解决.我放弃了RJS来执行这些操作,而是编写了一个ERB模板来输出所需的javascript.

Solved, sort of. I abandoned RJS for these actions, and instead wrote an ERB template that outputs the desired javascript.

RJS帮助程序与YUI Uploader的JS包装和转义一起使事情变得混乱了-现在,我只是在呈现所需的内容.

The RJS helpers coupled with the YUI Uploader's JS-wrapping-and-escaping were mangling things - now I'm just rendering exactly what I need.

这篇关于YUI3 Uploader + Rails rjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆