John Glabb John Glabb - 3 months ago 9
Javascript Question

how to disable xPage panel with CSJS

I'm trying to disable a panel on my xPage with CSJS.. but neither method works:

dojo.byId("#{id:panel1}").readonly=true;
dojo.attr("#{id:panel1}", "readonly", "true");
document.getElementById("#{id:panel1}").setAttribute("readonly", "true");

Answer

Use .attr('disabled', 'disabled'); for all input elements within your panel.

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:panel
        id="panel1">
        <xp:inputText
            id="inputText1"
            value="#{sessionScope.Test}"></xp:inputText>
    </xp:panel>
    <xp:br></xp:br>
    <xp:button
        value="Disable Input Field On Client Side"
        id="button1">
    <xp:eventHandler
        event="onclick"
        submit="false">
        <xp:this.script><![CDATA[
            var panel1 = document.getElementById("#{id:panel1}");
            dojo.query('input', panel1).attr('disabled', 'disabled');
        ]]></xp:this.script>
    </xp:eventHandler></xp:button>
</xp:view>
Comments