Triggering SPEF Form updates – Cascading drop-down or Visibility

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #1686

    Hello –

    I am changing / setting fields via javascript/jQuery within the SP Forms … After I change a field that has a local jQuery handler defined I will typically execute a $(selector).trigger(‘someaction’) to have the handler fire.

    Is there a way to call or trigger the SPEF update of form to have SPEF check conditional visibility and/or cascading drop-downs after I have changed a field value? I am able to change the field, however, I have not found a way to let SPEF know it needs to check visibility or cascading …. .trigger() does not seem to work

    As always … I LOVE EasyForms!!!!


    Joe McShea

    I’m not sure why that wouldn’t work. In the case of visibility based on the value of a field, I do just put a jQuery handler on the field to detect the change, so if trigger fires event handlers you’ve put on the field, I don’t know why it wouldn’t do the same for my handlers.

    As for cascading drop downs, I don’t actually implement that. It’s built into SPServices (written by Marc Anderson), I just use it. But I can tell you that under the hood it too is just attaching a jQuery handler to the change event of the parent drop down.

    I haven’t actually used trigger that much. When I get a chance, I’ll take a look and see if I can make some sense of it.


    • This reply was modified 2 years, 5 months ago by Joe McShea.
    Joe McShea

    Hi Jeff,

    Sorry to take so long getting back to you. I haven’t actually had time to figure out why trigger doesn’t cause my event handler to fire, but I have come up with a way for you to force the visibility rules to re-evaluation. SPEasyForms hangs off of an instance of jQuery, whose global name is spefjQuery. You can cause it to redraw with the following lines of JavaScript:

    var options = {};
    options.currentContext = spefjQuery.spEasyForms.sharePointContext.get(options);
    options.listContext = spefjQuery.spEasyForms.sharePointContext.getListContext(options);

    This is actually going re-evaluate everything (i.e. containers, adapters, and visibility), which may be more than you want, but it’s reasonably fast (lightning fast in chrome) and not any more jumpy than just evaluating the visibility rules. Unfortunately, there’s a lot of context that gets built up on the way to calling the visibility rules, and the visibility rules depends on that context, so it would be a bear to try and call it directly.


    • This reply was modified 2 years, 5 months ago by Joe McShea.
    • This reply was modified 2 years, 5 months ago by Joe McShea.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Scroll to top