<div id="OffLocations" style="width: 100%;"/>
<script>
//JS code...
var officeList = new Array();
<apex:repeat value="{!OfficesOpen}" var="off" >
officeList.push('<table style="width:100%; border: 1px solid Gray;" cellpadding="10px" cellspacing="0px">'
+'<tr>'
+'<td style="vertical-align:center;text-align:center;color: white;font-weight: bold;width:25%;">{!off.Slogan__c}</td>'
+'<td style="vertical-align:center;float:left;width:75%;"><i>{!off.Location}</i>'
+'<a id=\"xClose\" style="vertical-align:top;float:right;cursor: pointer;">X</a>'
+'</td>'
+'</tr>'
+'</table>');
</apex:repeat>
$("#xClose").click(function() {
alert('Test');
$("#OffLocations").hide();
});
</script>
This code is displaying the values in the page but the inline html < a > element is not working. When I move this tag anywhere out of script block, it is working fine. I've tried using the escape char '\', " etc. How do I escape the double quotes for the id "xClose" to call the function when clicking it or is the fault is somewhere else.
<a>
elements with the same idxClose
which makes jQuery confuse – highfive Jul 10 '14 at 4:49<apex:repeat />
is acceptable inside<script />
. If it does, when you have more than one record for yourOfficesOpen
, it's creating more than one<a />
– highfive Jul 10 '14 at 4:58apex:repeat
). – Boris Bachovski Jul 10 '14 at 5:00