Reputation: 4013
->
$('#new_category').bind "ajax:beforeSend", ->
notification = 'test'
$('#notification').html notification
The above code generates js code of
(function() {
return $('#new_category').bind("ajax:beforeSend", function() {
var notification;
notification = 'test';
return $('#notification').html(notification);
});
});
But the element with id notification is empty it is not working.
Upvotes: 2
Views: 132
Reputation: 81
Did you try with document.ready function
$(document).ready ->
$('#new_category').on "ajaxSend", ->
notification = 'test'
$('#notification').html notification
I hope this helps
Upvotes: 0
Reputation: 7680
You are just creating a function expression, not actually running it anywhere. Also, I'm not sure where you got that event name? Here is the list of jQuery AJAX events, I think you want the global 'ajaxSend'
event. Try this:
do ->
$('#new_category').on 'ajaxSend', ->
notification = 'test'
$('#notification').html notification
Upvotes: 1
Reputation: 8301
You'll want to do a few things:
.on()
in place of .bind()
if you are using jQuery 1.7+ajaxSend
eventSo your code should look like:
$ ->
$('#new_category').on "ajaxSend", ->
notification = 'test'
$('#notification').html notification
Upvotes: 1