Hi,
I have an Ajax form, which I want to prevent from being submitted if a
condition matched. Here is the code I have:
$(document).on 'page:update', (event) ->
$('#distribution_list').on 'ajax:before', (xhr, settings) ->
users = ($(user).data("id") for user in $(@).find("ul.active-users
li.user.new:not(.external-user) div.template-user"))
xhr.abort() if users.length is 0
$(@).find("input.user-ids[type='hidden']").val( JSON.stringify(users) )
Now when I am submutting the form, it is doing some unexpected to stuff when
the condition matched. Here goes the log:
Started PATCH "/distribution_lists/1" for 127.0.0.1 at 2015-10-18 13:43:04 +0530
Processing by DistributionListsController#update as HTML
Parameters: {"utf8"=>"✓", "distribution_list"=>{"names"=>"1",
"name"=>"all@all", "user_ids"=>"1 2"}, "commit"=>"Save List", "id"=>"1"}
Can't verify CSRF token authenticity
Completed 422 Unprocessable Entity in 2ms (ActiveRecord: 0.0ms)
[Rollbar] Reporting exception: ActionController::InvalidAuthenticityToken
[Rollbar] Exception not reported because Rollbar is disabled
Any idea, how to achieve what I am trying to do ?
--
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore,
if you write the code as cleverly as possible, you are, by definition, not
smart enough to debug it.
--Brian Kernighan
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/29506557.XX5YpcSF7J%40linux-wzza.aruprakshit.
For more options, visit https://groups.google.com/d/optout.