Fórumok

Changing the action attribute of the form tag

Dirk Ulrich, módosítva 12 év-val korábban

Changing the action attribute of the form tag

Junior Member Bejegyzések: 42 Csatlakozás dátuma: 2011.10.21. Legújabb bejegyzések
I know I can change a form's input field's value this way:
<aui:script use="aui-base">
A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
	A.one('#<portlet:namespace />currCatalogKey').val('${catalogueOptionsMapEntry.key}');
    });
</aui:script>


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

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


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

The form definition:
<portlet:renderurl var="loadChildrenURL">
   	<portlet:param name="action" value="loadChildren" />
</portlet:renderurl>
<portlet:renderurl var="loadParentURL">
   	<portlet:param name="action" value="loadParent" />
</portlet:renderurl>
<aui:form name="catalogEntries" id="catalogEntries" class="aui" method="post" action="<%=loadChildrenURL%>"></aui:form>
thumbnail
Sandeep Nair, módosítva 12 év-val korábban

RE: Changing the action attribute of the form tag

Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: Changing the action attribute of the form tag

Junior Member Bejegyzések: 42 Csatlakozás dátuma: 2011.10.21. Legújabb bejegyzések
Thank you:

I already tried (especially moving .action into the parentheses):
<aui:script use="aui">
	A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
		A.one('#<portlet:namespace />parentIdFld').val('${ catalogueOption.id }');
		alert(document.<portlet:namespace />catalogEntries.action);
		A.one('document.<portlet:namespace />catalogEntries.action').val('loadParentURL');
		alert(document.<portlet:namespace />catalogEntries.action);
		A.one("document.<portlet:namespace />catalogEntries.action('loadParentURL')");
		alert(document.<portlet:namespace />catalogEntries.action);
		A.one("document.<portlet:namespace />catalogEntries.action.val('loadParentURL')");
		alert(document.<portlet:namespace />catalogEntries.action);
		A.one('document.<portlet:namespace />catalogEntries.action="loadParent"');
		alert(document.<portlet:namespace />catalogEntries.action);
		A.one('document.<portlet:namespace />catalogEntries.action="&lt;%=loadParentURL%&gt;"');
		alert(document.<portlet:namespace />catalogEntries.action);
	});
</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:
<aui:script use="aui">
	A.one('#<portlet:namespace />getParentButtonForCatalogEntry_${ catalogueOption.id}').on('click', function(event) {
		document.<portlet:namespace />catalogEntries.action="&lt;%=loadParentURL%&gt;"';
		alert(document.<portlet:namespace />catalogEntries.action);
	});
</aui:script>