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="{&quot;key&quot;:&quot;value&quot;}">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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -