Fórum

Multiple instances of portlet and ajax

Miroslaw Hareza, modificado 9 Anos atrás.

Multiple instances of portlet and ajax

New Member Mensagem: 1 Data de Entrada: 24/03/15 Postagens Recentes
Hi all, I've written the following piece of code.

...  
<h1>Vehicle page</h1>  
<p>This is Vehicle page</p>  
<portlet:resourceurl var="submitURL" id="submitURL">
</portlet:resourceurl>

<aui:script use="aui-io-request,aui-node">
	Liferay.provide(window, 'save', function() {
		var A = AUI();
		A.io.request('${submitURL}', {
			method : 'POST',
			form : {
				id : 'mock'
			},
			on : {
				success : function() {
					A.one('#one').html(this.get('responseData'));
				}
			}
		});
	});
</aui:script>

<form:form method="POST" commandname="vehicle" id="mock" name="mock">  
<table>  
    <tbody><tr>  
        <td><aui:input name="name" /></td>  
    </tr>  
    <tr>  
        <td><aui:input name="model" /></td>  
    </tr>  
    <tr>  
        <td colspan="2">  
            <input value="Submit" type="button" onclick="save();">  
        </td>  
        <td></td>  
        <td></td>  
    </tr>  
</tbody></table>    
</form:form> 


I want each instance of the portlet to make ajax request on form submission. For example, I would have two portlets on web page and the data would be submitted for each portlet separately. That's why I've written aui:script and button which executes javascript function. But for two portlets the following javascript function is duplicated and when I try to submit data on second instance of portlet, submission occurs on first instance.

How to get rid of such behaviour and write portlet which can be instanceable and use ajax calls for submission?
thumbnail
Samuel Kong, modificado 9 Anos atrás.

RE: Multiple instances of portlet and ajax

Liferay Legend Postagens: 1902 Data de Entrada: 10/03/08 Postagens Recentes