[SalesForce]

I would like to know I would be able to convert the following codes into apex equivalent.

<button type="submit">
    <span></span>
</button>

I can't use <apex:commandButton>, as it is being rendered as <input> which is a single tag. I need to add an icon into the button that's why I have a <span> inside the button tag as I am using bootstrap.

Best Answer

To further illustrate Eric's comment, You would implement his suggestion like so:

Define your button (the button calls the javascript function doSomething) that is defined by the actionFunction:

<button type="submit" onclick="doSomething()">
    <span></span>
</button>

Define your controller action:

public PageReference doSomething(){
    //do something
    return null;
}

Define your actionFunction (this calls the controller action):

<apex:actionFunction name="doSomething" action="{!doSomething}"
    rerender="someApexObjectOnThePageEgAPanel" />
Related Topic