1. We suggest you do NOT update to Joomla 3.8.10 until we can resolve an issue it causes with caching in Fabrik. If you do install it, you'll need to disable Joomla's "System Cache" in the global System settings.
  2. Apologies for the recent server outage, a planned migration by our host provider to a new location turned into a bit of a nightmare.

trigger calc only if element validated

Discussion in 'Community' started by ontarget, Jan 12, 2018.

  1. ontarget

    ontarget Member

    Level: Professional
    Hi I am using a calc element to grab a group of elements and turn them into a bitly link.
    The calc is using ajax and is creating the bitly link before any elements have been populated.
    Is there any way of stopping a calc element from running until a few elements have been populated / validated?
    Thanks
     
  2. Sophist

    Sophist Well-Known Member

    Level: Community
    No. Not directly at least.

    But the calc element is running php, and the php can return an empty string if there is insufficient input to create a correct bitly link.

    I will leave it to others to comment on whether it is possible to stop the calc ajax from being fired by JS change events.
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    That's kind of a all or nothing thing. If you enable AJAX calc, it'll fire whenever one of the referenced elements changes.

    But yeah, just code the calc so it doesn't call the bitly API if all the parts you need aren't empty.

    Altough tbh, I wouldn't use a calc for this, I'd use a form submission script, running onBeforeProcess, to make sure you only call bitly once.

    -- hugh
     
  4. ontarget

    ontarget Member

    Level: Professional
    Cheers Sophist and Hugh - you set me on the right track.
     

Share This Page