Support » Plugin: Calculated Fields Form » Button click event

  • Resolved stephenm

    (@stephenm)


    Hi there…..how do you capture button click event in m jquery file??

    this event wont capture the button even

    jQuery.noConflict();
    (function ($) {

    function readyFn(i) {
    $(‘#fieldname4_1’).bind(‘click’,function()
    {
    alert(”);
    });
    }
    $(document).ready(readyFn);
    })(jQuery);

    Can you help please?

    S

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @stephenm

    Please, note that I’m the developer of the CFF plugin, and not for the jQuery framework, and your question is about how jQuery works.

    At the moment your code is evaluated you cannot ensure the fieldname4_1 field exists in the form, so, probably the piece of code $('#fieldname4_1') returns no element.

    There are two alternatives, you can to define your event in the bubbling process:

    
    jQuery(document).on('click', '#fieldname4_1', function(){ /* Your code here */ });
    

    More information in the documentation of jQuery.

    Or you can to define your function, for example:

    
    function my_code()
    {
    }
    

    and then, if the fieldname4 is a button, call your function from its onclick event (it is an attribute in the buttons’ settings):

    
    my_code();
    

    and that’s all.
    Best regards.

    Thanks so much for your reply….much appreciated.

    S

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.