Gary Wilkinson
Gary Wilkinson

Reputation: 27

XPages add form tag to disable Ajax

I'm using jQuery Mobile (1.2.0) and XPages (8.5.3) and want to disable the Ajax form submission as this appears to be preventing an image being saved (all other text fields are saved successfully).

Can I add data-ajax="false" to the form tag using the following?

<xp:this.attrs>
        <xp:attr name="data-ajax" value="false"></xp:attr>
</xp:this.attrs>  

I tried using Form in Themes (as per adding styleClass) but nothing was added, I could add the styleClass.

Upvotes: 1

Views: 376

Answers (2)

Naveen
Naveen

Reputation: 6936

Another alternative to this can be setting the createForm property in XPages to false. This would not generate form tag and allow you to create your own using xp:form. Then you can add your custom attribute using xp:this.attrs just like you did in your query. So you code would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" createForm="true">
    <xp:form id="myForm">
        <xp:this.attrs>
            <xp:attr name="data-ajax" value="false"></xp:attr>
        </xp:this.attrs>
        <!-- All the other controls go here -->
    </xp:form>
</xp:view>

This would generate the form tag looking something like this:

<form id="view:myForm" method="post" action="/myPath/myDatabase.nsf/xFormAttrs.xsp" class="xspForm" enctype="multipart/form-data" data-ajax="false">

Upvotes: 1

Sven Hasselbach
Sven Hasselbach

Reputation: 10485

Just add these lines to your theme:

<control mode="override">
    <name>Form</name>
    <property>
        <name>attrs</name>
        <complex type="xp_attr">
            <property>
                <name>name</name>
                <value>data-ajax</value>
            </property>
            <property>
                <name>value</name>
                <value>false</value>
            </property>
        </complex>
    </property>
</control>

Upvotes: 1

Related Questions