douchenbiao0916 2012-05-31 01:12
浏览 54
已采纳

Contenteditable vs输入替换

i'm working on an app that will have a listing of the data you've saved previously. if you have a typo, didn't enter all the data points originally, etc. you'll have the opportunity to edit the data chunk.

right now i have javascript getting the values of each element (that was created via foreach loop in php with data from the server) within a given chunk, saving it to an object and then replacing those elements (<p>) with textarea inputs then filling it with the data from the js object that grabbed it previously.

for one i'm having issues with escaping quotes from the dynamic content but also it feels like this may not be the most elegant solution.

in comes contenteditable.

basically: should i go that route and just make each of the elements in the data chunk contenteditable='true' on click of 'edit' button or is that too fishy with browser support?

is my current course a solid plan?

or is there a third (fourth, fifth, etc.) option?

thanks!

  • 写回答

2条回答 默认 最新

  • douao7937 2012-05-31 01:41
    关注

    Unless you specifically need the user to edit HTML content (or do complex syntax hilighting etc), go with input/textarea solution. Much cleaner, much more lightweight and easier to do. Contenteditable gets complicated really quickly and using something like tinyMCE or similar would probably be an overkill.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题