Update on the correct checkbox.

This commit is contained in:
Marin Jankovski 2014-12-26 15:55:58 +01:00
parent 16ebeedef2
commit 9fd061807e
1 changed files with 17 additions and 15 deletions

View File

@ -1,19 +1,21 @@
$ ->
$(":checkbox").change ->
id = $(this).val()
checked = $(this).is(":checked")
url = $(this).data("url")
$.ajax
type: "PUT"
url: url
dataType: "json"
data:
id: id
developers_can_push: checked
name = $(this).attr("name")
if name == "developers_can_push"
id = $(this).val()
checked = $(this).is(":checked")
url = $(this).data("url")
$.ajax
type: "PUT"
url: url
dataType: "json"
data:
id: id
developers_can_push: checked
success: ->
new Flash("Branch updated.", "notice")
location.reload true
success: ->
new Flash("Branch updated.", "notice")
location.reload true
error: ->
new Flash("Failed to update branch!", "alert")
error: ->
new Flash("Failed to update branch!", "alert")