1

I’m developing a wordpress plugin using qtip2.

Line breaking are not working. When trying to create an in-memory div via a JS code following HTML-encoding lost when attribute read from input field

The JS file should add the htmlDecode function code:

function htmlDecode(value){
  return JQuery('<div/>').html(value).text();
}

But unfortunately I'm getting "Unexpected token ILLEGAL" since WP adds a superfluous

 </p> 

and the post's code breaks (from chrome DevTools):

return jQuery(("</p>
<div/>").html(value)).text();             } });

Please advice

Community
  • 1
  • 1
Elad R
  • 11
  • 3
  • 1
    don't understand how this can get generated like that unless the code is being run through a WYSIWYG editor or something in wordpress admin. – charlietfl Jan 26 '15 at 06:43
  • Hi,The code is being run through a JS file which called by the plugin PHP file – Elad R Jan 28 '15 at 12:42
  • Actually not very clear at all what the issue really is. Can you create a demo that replicates it – charlietfl Jan 28 '15 at 13:17

1 Answers1

0

Solved by using the Javascript version of htmlDecode

function htmlDecode(html){
    var a = document.createElement( "a" );
    a.innerHTML = html;
    return a.textContent; 
   };
Elad R
  • 11
  • 3