How do I use apex:repeat inside the data-content of a bootstrap popover? If it's not possible, what's the best alternative? I would like to show a dynamic list inside of a bootstrap popover.

    <a class='danger' data-placement='above' 
   data-content="<apex:repeat value="{!testMap}" var="m"> <span>{!m}</span></apex:repeat>" 
   title="Title" href='#'>Click</a>

The above code does not compile. The error is

"Unknown property 'sampleController.m'"


You can't do this, because Visualforce expects proper XML, so you can't do complex things like loops inside an element attribute. Since you're already "inside" an element attribute, Visualforce will simply fail to compile instead of trying to render this properly. Instead, you'll want to take the roundabout way:

<a ... data-content="{!HTMLENCODE(popupOptions)}" title="Title" href="#">Click</a>

Where popupOptions is something like:

public String getPopupOptions() {
    return '<span>'+String.join(new List<String>(testMap.keySet()),'</span><span>')+'</span>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.