[Vtigercrm-developers] How to detect field value change on Edit View Save?

nilay khatri nilay.spartan at gmail.com
Thu Apr 5 15:57:54 GMT 2018


Right, you need to have a flag for that and set its value based on whether
it passed the validation or not.

If flag is set then you do not preventdefault.

On Thu, Apr 5, 2018 at 8:45 PM, Alan Lord <alanslists at gmail.com> wrote:

> Thanks - I managed to work it out by looking at the nodelist of the
> element - this doesn't change before the save, e.g.:
>
> var initialVal = el.attributes.getNamedItem('value').nodeValue;
>> var submitValue = jQuery(el).val();
>>
>
> But I have a bigger issue now.
>
> I am triggering my custom validation on the Vtiger_Edit_Js.recordPresaveEvent
> trigger and using e.preventDefault() to stop the process.
>
> But, if my custom validation passes and I try to either trigger this event
> again, or just submit the form, I get into a never ending loop of Presave,
> submit(), Presave, submit()...... :-(
>
> Any ideas how to stop/work around this?
>
> TIA
>
> Al
>
>
> On 04/04/18 17:10, nilay khatri wrote:
>
>> For the same scenario, for the required field on page load we store the
>> values in a static cache/array/object. And then on presaveevent compare the
>> form values with that in cache.
>>
>> On Wed, Apr 4, 2018 at 6:14 PM, Alan Lord <alanslists at gmail.com <mailto:
>> alanslists at gmail.com>> wrote:
>>
>>     I have a custom "validation" function. This is an ajax routine.
>>
>>     In Detail View (and Summary) I can stop the default event
>>     "PreAjaxSaveEvent", perform my checks and do what is necessary.
>>
>>     In Edit View though I am struggling to determine if a field has had
>>     its value altered before the user clicks the save button. I can trap
>>     the event "Vtiger_Edit_Js.recordPresaveEvent" OK but is there any
>>     way I can determine if a field's value has changed or not?
>>
>>     TIA
>>
>>     Al
>>
>>     _______________________________________________
>>     http://www.vtiger.com/
>>
>>
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>>
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20180405/315ba152/attachment.html>


More information about the vtigercrm-developers mailing list