Permalink
Browse files

Merge pull request #255 from funkedgeek/master

Fixed `select_advanced` cloning issue
  • Loading branch information...
2 parents a6374b9 + 07e8d0e commit f2fc7341d4ba294697f5b009fd4d4f8956680b03 @rilwis rilwis committed Mar 27, 2013
Showing with 13 additions and 7 deletions.
  1. +8 −4 js/clone.js
  2. +3 −2 js/color.js
  3. +2 −1 js/select-advanced.js
View
@@ -7,9 +7,9 @@ jQuery( document ).ready( function( $ )
var $clone_last = $input.find( '.rwmb-clone:last' ),
$clone = $clone_last.clone(),
$input, name;
-
+
$clone.insertAfter( $clone_last );
- $input = $clone.find( ':input' );
+ $input = $clone.find( ':input[class|="rwmb"]' );
// Reset value
$input.val( '' );
@@ -41,10 +41,14 @@ jQuery( document ).ready( function( $ )
// Fix datetime picker
if ( 'function' === typeof rwmb_update_datetime_picker )
rwmb_update_datetime_picker();
+
+ // Fix select_advanced
+ if ( 'function' === typeof rwmb_update_select_advanced )
+ rwmb_update_select_advanced();
}
// Add more clones
- $( '.add-clone' ).click( function()
+ $( '.add-clone' ).on( 'click', function()
{
var $input = $( this ).parents( '.rwmb-input' ),
$clone_group = $( this ).parents( '.rwmb-field' ).attr( "clone-group" );
@@ -73,7 +77,7 @@ jQuery( document ).ready( function( $ )
} );
// Remove clones
- $( '.rwmb-input' ).delegate( '.remove-clone', 'click', function()
+ $( '.rwmb-input' ).on( 'click', '.remove-clone', function()
{
var $this = $( this ),
$input = $this.parents( '.rwmb-input' ),
View
@@ -20,15 +20,16 @@ function rwmb_update_color_picker()
jQuery( document ).ready( function( $ )
{
- $( '.rwmb-input' ).delegate( '.rwmb-color', 'focus', function()
+ $( '.rwmb-input' ).on( 'focus', '.rwmb-color', function()
{
$( this ).siblings( '.rwmb-color-picker' ).show();
return false;
- } ).delegate( '.rwmb-color', 'blur', function()
+ } ).on( 'blur', '.rwmb-color', function()
{
$( this ).siblings( '.rwmb-color-picker' ).hide();
return false;
} );
+
rwmb_update_color_picker();
} );
View
@@ -6,10 +6,11 @@ function rwmb_update_select_advanced()
{
var $ = jQuery;
- $( '.rwmb-select-advanced' ).each( function ()
+ $( ':input.rwmb-select-advanced' ).each( function ()
{
var $this = $( this ),
options = $this.data( 'options' );
+ $this.siblings('.select2-container').remove();
$this.select2( options );
} );
}

0 comments on commit f2fc734

Please sign in to comment.