Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed `select_advanced` cloning issue #255

Merged
merged 2 commits into from

2 participants

@funkedgeek

select_advanced fields are now fullt cloneable. This fixes #252. Also replaced delegate with on since delegate is deprecated in jQuery

funkedgeek added some commits
@funkedgeek funkedgeek Fixed Error with cloning select_advanced fields
`select_advanced` fields are now fullt cloneable.  Also replaced
`delegate` with `on` since `delegate` is deprecated in jQuery
385f6d3
@funkedgeek funkedgeek Removed delegate from event handlers 07e8d0e
@rilwis rilwis merged commit f2fc734 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 27, 2013
  1. @funkedgeek

    Fixed Error with cloning select_advanced fields

    funkedgeek authored
    `select_advanced` fields are now fullt cloneable.  Also replaced
    `delegate` with `on` since `delegate` is deprecated in jQuery
  2. @funkedgeek
This page is out of date. Refresh to see the latest.
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
12 js/clone.js
@@ -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
5 js/color.js
@@ -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
3  js/select-advanced.js
@@ -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 );
} );
}
Something went wrong with that request. Please try again.