-
-
Save benhuson/2228781 to your computer and use it in GitHub Desktop.
/* Detach carousel - same as destroy but content is not removed */ | |
detach: function() { | |
this.stopAutoplay(); | |
this._itemsWrapper.unbind(this._downEvent); | |
$(document).unbind(this._moveEvent).unbind(this._upEvent); | |
$(window).unbind(this._resizeEvent); | |
if(this.settings.keyboardNav) { | |
$(document).unbind("keydown.touchcarousel"); | |
} | |
if (this._dragContainer.parent().hasClass('touchcarousel-wrapper')) { | |
this.setXPos(0); | |
this._dragContainer.unwrap(); | |
} | |
}, |
I added the detach function after the destroy function around line 666 in jquery.touchcarousel-1.0.js
Seems to work OK for me. Just have to make sure you only call it on an active version of the carousel?
Where about's in the minified version did you add it?
It won;t work if you just add it at the end I don't think.
You really need the non-minified version to do it
I added it after the 'prev' function was declared. Thus, right after: "{c=(this._jq2-1)_this._hs2}else{c=0}}else{c=d_this._hs2}}this.goTo(c,a)}," (just ctrl+f to find that)
I de-minified mine and I see where the problem lies. After minifying the functions _[something] have all be renamed to shorter ones, therefore e.g. _Itemswrapper does not exist, therefore you cannot unbind it.
I got it working, thanks for everything :) In addition I added the option to remove the pagingNav when present.
Cool, glad it works for you.
Hi!
When using your detach function, which I missed in the official release - thanks for that - , I am getting the error:
4Uncaught TypeError: Cannot call method 'unbind' of undefined
I am using jQuery 1.7.2 and touchcarousel 1.0. I am calling your function using:
carouselInstance.detach();
and copy-pasted the function into the script, after the entire 'prev' function was declared. That should be ok, right?
You have any idea how to solve this? Thanks in advance!
Cheers