JotForm Anywhere: Is there any way to unsuscribe jotform.formCreated

  • Profile Image
    Skelo
    Asked on April 01, 2013 at 05:15 PM

    I'm currently using jotForm Anywhere to build an app inside a website generator, it allows to duplicate the apps on demand, since these events are fired in the global context I'm having troubles when more than one form is generated on the same page, so I would like to know if there's any public method to unsuscribe this specific event so the first instance doesn't receive that message.

  • Profile Image
    EltonCris
    Answered on April 01, 2013 at 06:19 PM

    Hi Skelo,

    I am not quite sure if I have understand your question correctly. If you don't like to received notifications on a form, simply delete its notification. Here's How to Delete Notifications/Autoresponder. You can do that when you edit your form on the embedded page.

    If this isn't what you mean about the JotForm Anywhere feature, please provide a screenshot that describes the problem in question so we can check it further. Thank you!

  • Profile Image
    Skelo
    Answered on April 01, 2013 at 07:24 PM

    Thanks Elton, as per documentation:
    http://www.jotform.com/anywhere#documentation

    quote:
    JotformAnywhere.subscribe

    JotformAnywhere.subscribe method attaches handler to an event defined by JS library and invokes your callback when the event fires.

    ----------

    My issue is that within each app I attach this handler so when I have 'n' apps on the same page the event is listened 'n' times (being 'n' the number of iterations per app), in consequence my callback gets fired 'n' times, my question is if there's some way to attach/dettach this event in some kind of context, something like:

    var receiver = document.getElementById('formReceiver');

    $(receiver).bind('jotform.formCreated', function(response){
       // do stuff when this form is created

      $(this).unbind('jotform.formCreated', false); //this would be great to have
    });

    instead of:
    JotformAnywhere.subscribe
    ("jotform.formCreated", function(response){
     // do stuff each time a form is created
    } );

    I've looked under the hood of JotformAnywhere's js and i found an unsuscribe method which I think receives a token, but I'm not sure how to use it.

  • Profile Image
    EltonCris
    Answered on April 01, 2013 at 08:01 PM

    I see, thanks for the details. Since the feature is "new" and I'm not quite familiar with its usage. I have forwarded your thread to the API team. You will received updates here once they responded to this thread.

    Thank you for your patience!

  • Profile Image
    Skelo
    Answered on April 01, 2013 at 08:04 PM

    awesome, thanks for your prompt response, very appreciated!

  • Profile Image
    mdikici
    Answered on April 02, 2013 at 03:03 AM

    Hi Skelo,

    I understand your need and will implement unsubscribe method shortly, (documentation will updated accordingly). Thanks for the feedback.

    Regards.

     

    EDIT: when you called JotformAnywhere.subscribe("xxxx", function()...), this method returns a token which can be used as id (token) of this subscribtion. Later you can use this token to unsubscribe.

    e.g.:

    var subId = JotFormAnyWhere.subscribe("jotform.formCreated", function(){});

    ....

    JotFormAnyWhere.unsubscribe(subId);

     

    I am stiil looking for a better method for unsubscribe action, for now you can use this.

  • Profile Image
    Skelo
    Answered on April 02, 2013 at 12:33 PM

    thanks mdikici, I'll use it that way and come back to you if any comment or question.