Forums

Home » Alloy UI » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dirk Ulrich
Changing the action attribute of the form tag
December 27, 2011 1:29 PM
Answer

Dirk Ulrich

Rank: Junior Member

Posts: 42

Join Date: October 21, 2011

Recent Posts

I know I can change a form's input field's value this way:
1<aui:script use="aui-base">
2A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
3    A.one('#<portlet:namespace />currCatalogKey').val('${catalogueOptionsMapEntry.key}');
4    });
5</aui:script>


but how can I dynamically change the value of the form's action attribute? It doesn't work this way:

1<aui:script use="aui-base">
2A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
3    alert(document.<portlet:namespace />catalogEntries.action);
4    A.one('document.<portlet:namespace />catalogEntries').action.val('${loadParentURL}');
5    });
6</aui:script>


The alert works well and shows the current value of the action attribute but the subsequent statement fails.

The form definition:
1<portlet:renderURL var="loadChildrenURL">
2       <portlet:param name="action" value="loadChildren" />
3</portlet:renderURL>
4<portlet:renderURL var="loadParentURL">
5       <portlet:param name="action" value="loadParent" />
6</portlet:renderURL>
7<aui:form name="catalogEntries" id="catalogEntries" class="aui" method="post" action="<%=loadChildrenURL%>">
Sandeep Nair
RE: Changing the action attribute of the form tag
December 27, 2011 9:37 PM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1692

Join Date: November 5, 2008

Recent Posts

Can you try

document.<portlet:namespace />catalogEntries.action = "<%=loadParentURL%>";

or

document.<portlet:namespace />catalogEntries.action ='<portlet:renderURL><portlet:param name="action" value="loadParent" /</portlet:renderURL>'

Regards,
Sandeep
Dirk Ulrich
RE: Changing the action attribute of the form tag
December 28, 2011 4:38 AM
Answer

Dirk Ulrich

Rank: Junior Member

Posts: 42

Join Date: October 21, 2011

Recent Posts

Thank you:

I already tried (especially moving .action into the parentheses):
 1<aui:script use="aui">
 2    A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
 3        A.one('#<portlet:namespace />parentIdFld').val('${ catalogueOption.id }');
 4        alert(document.<portlet:namespace />catalogEntries.action);
 5        A.one('document.<portlet:namespace />catalogEntries.action').val('loadParentURL');
 6        alert(document.<portlet:namespace />catalogEntries.action);
 7        A.one("document.<portlet:namespace />catalogEntries.action('loadParentURL')");
 8        alert(document.<portlet:namespace />catalogEntries.action);
 9        A.one("document.<portlet:namespace />catalogEntries.action.val('loadParentURL')");
10        alert(document.<portlet:namespace />catalogEntries.action);
11        A.one('document.<portlet:namespace />catalogEntries.action="loadParent"');
12        alert(document.<portlet:namespace />catalogEntries.action);
13        A.one('document.<portlet:namespace />catalogEntries.action="<%=loadParentURL%>"');
14        alert(document.<portlet:namespace />catalogEntries.action);
15    });
16</aui:script>


None of these statements worked. Your suggestions led to the following solution...

The solution is, NOT to use A.one but simply call:
1<aui:script use="aui">
2    A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
3        document.<portlet:namespace />catalogEntries.action="<%=loadParentURL%>"';
4        alert(document.<portlet:namespace />catalogEntries.action);
5    });
6</aui:script>