Closed onemanstartup closed 10 years ago
Do you use CoffeeScript?
If init
shortcut return object, evil.block
will call every method of this object. It was used in old API to split logic:
evil.block '.gallery-control', ->
initSlideshow: ->
# do some code
initControls: ->
# do some code
I know, that is bad logic, but unfortunately, I have a lot of legacy code and can’t change this shortcut API in current releases :(.
Sorry, for some delay. I return from vacation only today :).
BTW, can you show your code example? Maybe problem is in another place.
Hi. Yeah I know :) Привет) Don't work
evil.block '.ajax-autocomplete', ->
$(@input_autocomplete).autocomplete
source: (request, response) =>
dependent_params = ''
$(@dependent).each (index, element) ->
dependent_params += '&dependent' + $(element).serialize().replace(/.+%5B/, '%5B')
$.ajax
url: $(@input_autocomplete).data('url')
data: '&start_with=' + $(@input_autocomplete).val() + dependent_params
dataType: "json"
success: (data) ->
response data
minLength: 2
appendTo: $(@input_autocomplete).parent()
select: (event, ui) =>
$(@result_autocomplete).val(ui.item.id)
works
evil.block '.ajax-autocomplete',
init: ->
$(@input_autocomplete).autocomplete
source: (request, response) =>
dependent_params = ''
$(@dependent).each (index, element) ->
dependent_params += '&dependent' + $(element).serialize().replace(/.+%5B/, '%5B')
$.ajax
url: $(@input_autocomplete).data('url')
data: '&start_with=' + $(@input_autocomplete).val() + dependent_params
dataType: "json"
success: (data) ->
response data
minLength: 2
appendTo: $(@input_autocomplete).parent()
select: (event, ui) =>
$(@result_autocomplete).val(ui.item.id)
Yeap, problem is that $(@input_autocomplete).autocomplete
returns object and CoffeeScript returns all last code line (like Ruby).
I recommend to use non-shorcut or to but false
at end on shortcut.
I can fix this API only in next major version, when I will remove old API.
It is minor issue, thanks.
https://github.com/ai/evil-blocks/blob/master/lib/evil-blocks.js#L195 This is not working.