Clone Add/Remove Event Trigger

Support General Clone Add/Remove Event TriggerResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31806
    pluginovenpluginoven
    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');
        }   
    });
    #31815
    Long NguyenLong Nguyen
    Moderator

    Great!
    Thanks for sharing your solution.

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