 			@config.collapseOptgroups = on if @$el.is ".select7_collapse_optgroups"
 			{templateOptionFnName, templateOptgroupFnName, templateCurrentFnName} = @$el.data()
 			if templateOptionFnName
-				@config.optionTemplate = (option) ->
-					window[templateOptionFnName] option
+				@config.optionTemplate = (args...) ->
+					window[templateOptionFnName].call @, args...
 			if templateOptgroupFnName
-				@config.optgroupTemplate = (optgroup) ->
-					window[templateOptgroupFnName] optgroup
+				@config.optgroupTemplate = (args...) ->
+					window[templateOptgroupFnName].call @, args...
 			if templateCurrentFnName
-				@config.currentTemplate = (option) ->
-					window[templateCurrentFnName] option
+				@config.currentTemplate = (args...) ->
+					window[templateCurrentFnName].call @, args...
 			@updateItemsAndSelected()
 			@opened = no
 			@pwnSelect()

###
@name jquery-select7
@version 1.2.4
@author Se7enSky studio <info@se7ensky.com>
###
###! jquery-select7 1.2.4 http://github.com/Se7enSky/jquery-select7 ###

plugin = ($) ->
	

			generate$option = (option) =>
				$option = $ """<li class="select7__option #{option.class or ""}"></li>"""
				if @config.optionTemplate
					$option.html @config.optionTemplate.call @, option, @items
				else
					$option.text option.title
				$option.addClass "select7__option_disabled" if option.disabled
