Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jeditable encoding & turns into & when editing

I'm using jeditable and having some encoding issues. If I enter &, save, and then try to edit it shows up as &.

Easily reproducible here: http://www.appelsiini.net/projects/jeditable/default.html

Edit the Normal textarea and enter &&&, save and then edit again and you'll see it. How can I fix this?

like image 725
AnApprentice Avatar asked Jun 22 '11 18:06

AnApprentice


3 Answers

A way better solution.... even for compressed js file.

Search for line :

self.revert     = $(self).html();

replace with

self.revert     = $(self).text();

Solution no1 would not work if you would like to have "&" in your editable field Sollution no2 is version dependent

like image 188
Alex Avatar answered Nov 08 '22 10:11

Alex


solution:

input_content = $('<textarea/>').html(self.revert).val();

This converts the input to a html_safe type format. This goes in around line 247 to replace:

input_content = self.revert; 
like image 45
AnApprentice Avatar answered Nov 08 '22 11:11

AnApprentice


I encountered the same issue, here is what I edited in the jquery.jeditable.js (v 1.7.1) file :

replace l.176 :

self.editing    = true;
self.revert     = $(self).html(); 
$(self).html('');

by

self.editing    = true;
self.revert     = $(self).html().replace(/&amp;/g,"&");
$(self).html('');

This is a simple regexp replacing &amp; by & and it did the job !

like image 1
Xasz Avatar answered Nov 08 '22 12:11

Xasz