I want to put more than one jquery extension in the same file. I have the following in one file:
do($ = jQuery) ->
$.fn.addAlternatingStyles = ->
$(@).children('tr').not('.exclude').hover(
-> $(@).addClass('hoverrow')
-> $(@).removeClass('hoverrow')
)
do($ = jQuery) ->
开发者_StackOverflow中文版 $.fn.stripe = ->
$(@).children('tr:even').addClass('evenrow')
$(@).children('tr:odd').addClass('oddrow')
It does not recognise the second extension, i.e. stripe.
Can anyone point me in the right direction?
You don't need to use separate do
.
do($ = jQuery) ->
$.fn.addAlternatingStyles = ->
$(@).children('tr').not('.exclude').hover(
-> $(@).addClass('hoverrow')
-> $(@).removeClass('hoverrow')
)
$.fn.stripe = ->
$(@).children('tr:even').addClass('evenrow')
$(@).children('tr:odd').addClass('oddrow')
精彩评论