Error when editing row with natural key containing @
Error when editing row with natural key containing @
When using a Natural Key such as an email address, the editor sends the data ok:
{
action:"edit"
data:{name@oldaddress.com:
{user_ID: "999999999", email_ID: "name@newaddress.com"}
}
}
The server updates the the email address and responds to the client with:
{
data: [
{email_ID: "name@newaddress.com", odr: "1", dft: "0", verified: "1"}
]
}
All good so far.
HOWEVER, when parsing the returned data, datatables issues the following error:
datatables.min.js:14 Uncaught Error: Syntax error, unrecognized expression: #name@oldaddress.com
Testing:
If the email address has a backslash inserted before the @, then the error goes away so:
name\@oldaddress.com - CAN BE UPDATED FINE
name@oldaddress.com - THROWS ERROR IN THE CLIENT
Is the solution to this to have Datatables escape the '@' symbol?
Replies
.
name@oldaddress.com
should read:
name@oldaddress\.com
I forgot to double-escape.
Thanks for letting me know about that. There was an error in the post Ajax handling in Editor for it handles id elements which special characters. I've committed the fix now and it will be in 1.7.1, which will be release in January. Until then, I can send you a 1.7.1-dev version with the fix - is the e-mail address for your forum account the one to use?
Thanks,
Allan
Hi Allan,
Thanks!
I managed a workaround for which involved adding slash to the database output, and in datatables I put:
And separately in DataTable() columns: I put a render:
The above ensured that the index kept the escaped @, the table displayed the unescaped @ and the editor field also provided the unescaped @.
While it took me a while to figure out, I feel I learned a lot about DT in the process. Your fix will allow me to exit elastic band mode!
Thanks - yes I do use the same email, please do send!
Steve