0

我有一个 javascript 代码,它以表格格式显示数据,当将鼠标悬停在第一列上时,它会显示其他详细信息。悬停在代码上是使用 jquery 工具提示和 html 的 title 属性。该代码在大多数情况下都可以正常工作,但是如果我在悬停中显示的字段之一具有“符号,它将破坏所有记录,并且悬停和主要数据一起显示,并且悬停在这些行上不起作用。

下面是我的代码的快照

var medicationName = medJSON.MED_DETAILS[medIdx1].ORDER_NAME;
     var orderdetails = medJSON.MED_DETAILS[medIdx1].ORD_DETAILS;
      var comments = medJSON.MED_DETAILS[medIdx1].ORD_COMMENTS;
      var reqStart = medJSON.MED_DETAILS[medIdx1].REQ_ST_DT;
      var originalStart = medJSON.MED_DETAILS[medIdx1].ORIG_ORD_DT;
      var lastDose = medJSON.MED_DETAILS[medIdx1].LAST_DOSE;
      var nextDose = medJSON.MED_DETAILS[medIdx1].NEXT_DOSE;
      var stopDt = medJSON.MED_DETAILS[medIdx1].STOP_DT_TM;
      var stopReason = medJSON.MED_DETAILS[medIdx1].STOP_REASON;
      var enteredBy = medJSON.MED_DETAILS[medIdx1].ORDER_ENTERED_BY;
      var status = medJSON.MED_DETAILS[medIdx1].ORD_STATUS;
      var simpleDetails = medJSON.MED_DETAILS[medIdx1].CLIN_DISP_LN;
      if(nextDose.length == 0)
      {
      nextDose = "Not Defined";
      }
      var medHover = ["<table><tr><td><b>Medication:</b></td><td>",medicationName,"</td></tr>"
                        ,"<tr><td><b>Details:</b></td><td>",simpleDetails,"</td></tr>"
                        //,"<tr><td><b>Order Comments:</b></td><td>",comments,"</td></tr>"
                          ,"<tr><td><b>Request Start:</b></td><td>",reqStart,"</td></tr>"
                          ,"<tr><td width = 200px><b>Original Order Date/Time:</b></td><td>",originalStart,"</td></tr>"
                          ,"<tr><td><b>Last Documented Dose:</b></td><td>",lastDose,"</td></tr>"
                          ,"<tr><td><b>Next Scheduled Dose:</b></td><td>",nextDose,"</td></tr>"
                          ,"<tr><td><b>Stop Date/Time:</b></td><td>",stopDt,"</td></tr>"
                          ,"<tr><td><b>Stop Reason:</b></td><td>",stopReason,"</td></tr>"
                          ,"<tr><td><b>Order Entered By:</b></td><td>",enteredBy,"</td></tr>"
                          ,"<tr><td><b>Status:</b></td><td>",status,"</td></tr>"
                          ,"</table>"]


     tempStr1.push("<tr class = 'evenrow' ><td class = 'cmedname custhvr' title=\"",medHover.join(""),"\">",medicationName,"</td><td> ",simpleDetails,"</td></tr>")  

谢谢,锡德

4

1 回答 1

0

使用以下方法处理 medHover:

medHover.join("").replace('\"', '&quot;');

这会将引号字符替换为可用于 HTML 的值。

于 2013-04-24T21:41:54.677 回答