For a number of reasons, I got code that requires storing JSON-serialized objects inside HTML attribute tags.
However, I had a problem when one of my serialized json objects contains an apostrophe and, as a result, breaks jQuery.
Basically this behavior ...
Here is the table header definition.
<table class='DraggableRowTable' RowData='{"AuthorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Created":"\/Date(1319429903223+1100)\/","EditorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Modified":"\/Date(1319429903223+1100)\/","AssignedToID":"7daef058-d84c-43f5-9db1-8011c59673ee","DetailedTaskID":"169ea939-7cb7-4599-9c2a-9e8ef4dee641","Duration":4.0000,"EndDate":"\/Date(1319497200000+1100)\/","ManualCalculation":false,"RoleID":"944f0ea3-4312-4f14-9d00-c968a647996a","Sequence":14,"StartDate":"\/Date(1319429872333+1100)\/","Status":0,"SubSequence":0,"Task":{"AuthorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Created":"\/Date(1319172394650+1100)\/","EditorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Modified":"\/Date(1319172394650+1100)\/","AssignedToID":"7daef058-d84c-43f5-9db1-8011c59673ee","Duration":4,"IsActive":true,"ProductID":"dad82b06-7d28-4255-bf02-f709eeed64cd","RoleID":"944f0ea3-4312-4f14-9d00-c968a647996a","Sequence":14,"TaskDescription":"es reviewer is to review the following fields and provide feedback to the writer if they' need fixing:\u000d\u000a*description\u000d\u000a*key learning objectives\u000d\u000a*educational value statements","TaskID":"6f577537-ce4a-46cd-9eb6-29bd5756ab26","TaskName":"educational soundness review"},"TaskID":"6f577537-ce4a-46cd-9eb6-29bd5756ab26","WorkOrder":{"AuthorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Created":"\/Date(1319429872333+1100)\/","EditorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Modified":"\/Date(1319429872333+1100)\/","IsActive":true,"Priority":1,"ProductID":"dad82b06-7d28-4255-bf02-f709eeed64cd","Qty":1,"StartDate":"\/Date(1319429872333+1100)\/","Status":0,"Subtitle":null,"WorkOrderDescription":null,"WorkOrderExternalID":43,"WorkOrderID":"66c40ff8-56e1-4009-89ab-989b0e25d120","WorkOrderName":"Work order #43"},"WorkOrderID":"66c40ff8-56e1-4009-89ab-989b0e25d120"}'>
And here is the code.
var Data = $(GridRow).find(".DraggableRowTable").attr("RowData"); //Data = "{"AuthorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Created":"\/Date(1319429903223+1100)\/","EditorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Modified":"\/Date(1319429903223+1100)\/","AssignedToID":"7daef058-d84c-43f5-9db1-8011c59673ee","DetailedTaskID":"169ea939-7cb7-4599-9c2a-9e8ef4dee641","Duration":4.0000,"EndDate":"\/Date(1319497200000+1100)\/","ManualCalculation":false,"RoleID":"944f0ea3-4312-4f14-9d00-c968a647996a","Sequence":14,"StartDate":"\/Date(1319429872333+1100)\/","Status":0,"SubSequence":0,"Task":{"AuthorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Created":"\/Date(1319172394650+1100)\/","EditorID":"652c90e4-ffef-49c5-9217-0ff39a461011","Modified":"\/Date(1319172394650+1100)\/","AssignedToID":"7daef058-d84c-43f5-9db1-8011c59673ee","Duration":4,"IsActive":true,"ProductID":"dad82b06-7d28-4255-bf02-f709eeed64cd","RoleID":"944f0ea3-4312-4f14-9d00-c968a647996a","Sequence":14,"TaskDescription":"es reviewer is to review the following fields and provide feedback to the writer if they" //As you can see, it all breaks here...
So, I think, Iβm wondering, firstly, is it correct to have apostrophes in HTML attributes (IE: does it support the HTML standard), and secondly (depending on the answer to the first) should jQuery be able to correctly return this attribute?