Question

I have this function :

 if (location.locationUrl != '') {
content += "<a class='viewLocationPage btn corePrettyStyle'  " +   
(mapObject.options.openinnew == false ? "" : "target='_blank'") +  
" href='" + location.locationUrl + "' >View location detail</a>";
        }

and I've added the rel attribute like this:

if (location.locationUrl != '') {
            content += "<a class='viewLocationPage btn corePrettyStyle'  " + 
            (mapObject.options.openinnew == false ? "" : "target='_blank'") +
            "rel='prettyPhoto[iframes]'" + " href='" + location.locationUrl + "' >View location detail</a>";
        }

but is not working, it doesn't add any rel attribute into the markup. Any suggestions on how can I make this work ?

Was it helpful?

Solution

Since you're already using jQuery, it'd be easier to create the element with the jQuery constructor:

if (location.locationUrl != '') {
    $('<a>', {
        'class': 'viewLocationPage btn corePrettyStyle',
        target: mapObject.options.openinnew ? '_blank' : '',
        rel: 'prettyPhoto[iframes]',
        href: location.locationUrl,
        text: 'View location detail'
    }).appendTo('#selector');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top