clone.js Code Issue

Support MB Group clone.js Code Issue

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3716
    jpomrankyjpomranky
    Participant

    Hello,

    We were having an issue with the new meta box group clone functionality in that we couldn't add additional items when editing a page. One of my developers provided me with the following notes and code update that was made to fix the issue. We're not sure if this is a permanent fix but hopefully it lets you know where the issue is. Let me know. Thanks.
    ----------------------------------------------
    […] here is what I have done to fix the metabox group functionality issue: to populate a metabox group in a page you have to click on "+ add more" button so that it creates a new item to be populated.

    This new item is inside a form to be submitted, the indexes created for these new item names should increase but there is a bug in JS in wp-content\plugins\meta-box\js\clone.js about line 21.

    I changed this:

    if ( name && !$field.closest( '.rwmb-group-clone' ).length ){ $field.attr( 'name', cloneIndex.replace( index, name, '[', ']', false ) ); }

    to this:

    if ( name){ $field.attr( 'name', cloneIndex.replace( index, name, '[', ']', false ) ); }

    Content item always have a ( '.rwmb-group-clone' ) close so I removed that from the condition. Now the condition is true and the index is incremented, it works now, not 100% sure if that could be a definitive fix but at least plugin author can see what the problem is.

    #3719
    Anh TranAnh Tran
    Keymaster

    Hi @jpomranky,

    Can you please check the version of the Group extension you're using? I think I fixed this bug in the extension and keep the clone.js file untouched.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘clone.js Code Issue’ is closed to new replies.