json - How to insert single quotes with redactor.js? -
i'm building little custom plugin redactor 8.2.2 customize links.
this example of i'm trying achieve :
var inserttext = "<a href='#target' data-rel='{\"key\":\"value\"}'>text</a>"; /* later in code... */ this.execcommand('inserthtml', inserttext);
i end code in editor :
<a href="#target" data-rel="{"key":"value"}">text</a>
which saved double quotes in database, leading further troubles:
<a href="#target" data-rel="{"key";"value"}">text</a>
is there way force single quotes?
i tried use inserthtmladvanced
, no link inserted.
edit__
it seems problem not way inserttext
formated. whatever format is, double quotes added if data-rel attribute presents value between single quotes. therefore, solution might find workaround inserthtml
command, or post-process inserted code.
edit___
according imperavi support, json should not used data-*. found workaround deleting quotes in json string, , adding them later before parsing data-rel value. however, guess not efficient , nicest solution....
use this:
this.execcommand('inserthtml', inserttext.replace(/'/g, "\\'"));
Comments
Post a Comment