Custom Fields
Re-Envisioned
Support General Clone Add/Remove Event Trigger

  • Creator
    Topic
  • #31806
    Resolved pluginoven
    Participant

    Hopefully this will save others wasted time trying to hack into add/remove clone to trigger your own events.

    /* Tie into the un-documented mb_change metabox event
     *  this will only trigger on a clone field with an ID 'event_start'
     *  notice the selector is anything element that starts with this ID
     *  this is required because the add clone event is triggered from
     *. the last cloned element with an unique random ID, something like
     *. event_start_awr34s7wdsh
    */
    $(document).on('mb_change', '[id^=event_start]', function(e) {
        if( $(this).prop('id') == 'event_start'){
            console.log('clone was removed');
        }
        else{
            //element id something like: event_start_awr34s7wdsh
            console.log('clone was added');
        }   
    });
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #31815
    Long Nguyen
    Moderator

    Great!
    Thanks for sharing your solution.

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