Created
April 29, 2012 18:54
-
-
Save distracteddev/2552641 to your computer and use it in GitHub Desktop.
SafeClone to for jQuery UI so that it plays nice with Ember.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.extend({ | |
safeClone: function() { | |
var clone; | |
clone = $(this).clone(); | |
clone.find('script[id^=metamorph]').remove(); | |
clone.find('*').each(function() { | |
var $this; | |
$this = $(this); | |
return $.each($this[0].attributes, function(index, attr) { | |
if (attr.name.indexOf('data-bindattr') === -1) { | |
return; | |
} | |
return $this.removeAttr(attr.name); | |
}); | |
}); | |
if (clone.attr('id') && clone.attr('id').indexOf('ember') !== -1) { | |
clone.removeAttr('id'); | |
} | |
clone.find('[id^=ember]').removeAttr('id'); | |
return clone; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment