Foros de discusión

Liferay Auto Fields onAdd function issue

thumbnail
Gurumurthy Godlaveeti, modificado hace 10 años.

Liferay Auto Fields onAdd function issue

Regular Member Mensajes: 208 Fecha de incorporación: 12/08/11 Mensajes recientes
Hello All,


I would like to raise javascript event one new row added by clicking on 'Add' (+) button in Liferay Auto Fields. I followed Liferay Javascript API to know about calling javacsript function once we clicked on 'Add' (+) button but it's not getting raised.

My HTML Code:
<div class="lfr-form-row lfr-form-row-inline">
			   <div class="row-fields">
					<aui:input fieldParam="emailAddress" id="emailAddress1" name="emailAddress" label="Email" />
					<aui:input fieldParam="token" id="token1" name="token" label="Token" />
			  </div>
			</div>


My Javascript Code

<aui:script use="liferay-auto-fields">
		new Liferay.AutoFields(
    	{
    		init: function() {
			        alert('The automagic fields are now ready to use.');
			 },
    		contentBox:'#token-entries-manual',
    		fieldIndexes:'<portlet:namespace />tokenEntriesIndexes',
    		onAdd: function(newField) {
				alert('This field got added.');
			}
    	}).render();
    </aui:script>



Can someone help me to know if I missed any steps?

Thanks in advance...!
thumbnail
Gurumurthy Godlaveeti, modificado hace 10 años.

RE: Liferay Auto Fields onAdd function issue

Regular Member Mensajes: 208 Fecha de incorporación: 12/08/11 Mensajes recientes
Even onRemove & init functions also not called.


<aui:script use="liferay-auto-fields">
		new Liferay.AutoFields(
    	{
    		init: function() {
			        alert('The automagic fields are now ready to use.');
			 },
    		contentBox:'#token-entries-manual',
    		fieldIndexes:'<portlet:namespace />tokenEntriesIndexes',
    		onAdd: function(newField) {
				alert('This field got added.');
			},
			onRemove: function() {
				alert('The last field was removed.');
			}
    	}).render();
    </aui:script>
thumbnail
Angelo Giove, modificado hace 9 años.

RE: Liferay Auto Fields onAdd function issue

New Member Mensajes: 8 Fecha de incorporación: 18/03/13 Mensajes recientes
According to source code for 6.2 ga2
[indent]https://github.com/liferay/liferay-portal/blob/6.2.x/portal-web/docroot/html/js/liferay/auto_fields.js[/indent]
the event for "add row" is named "clone".
In your jsp you can try the following code:
<aui:script use="liferay-auto-fields">
var autoFields = new Liferay.AutoFields(
        {
           contentBox:'#token-entries-manual',
           fieldIndexes:'<portlet:namespace />tokenEntriesIndexes'
       });

// add row event
autoFields.on("clone", function(newField) {
               alert('This field got added.');
          });

// delete row event
autoFields.on("delete", function() {
               alert('The last field was removed.');
          });

autoFields.render();
</aui:script>


Hope this helps.
Ajeet Singh, modificado hace 8 años.

RE: Liferay Auto Fields onAdd function issue

New Member Mensajes: 14 Fecha de incorporación: 27/03/12 Mensajes recientes
Thanks Angelo, It worked perfectly.