Does this apply OK? Does it work properly?
----- Original Message -----
From: "Ladislav Martincik" <lmartinc(a)redhat.com>
To: mtaylor(a)redhat.com
Cc: deltacloud-devel(a)lists.fedorahosted.org
Sent: Thursday, October 21, 2010 11:45:17 AM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: Re: [deltacloud-devel] [PATCH aggregator] BZ 643810 Added JS to manage users
pages to prevent multiple selection of users
----- mtaylor(a)redhat.com wrote:
From: martyntaylor <mtaylor(a)redhat.com>
---
src/app/views/users/index.haml | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/app/views/users/index.haml
b/src/app/views/users/index.haml
index df9def1..854cd2e 100644
--- a/src/app/views/users/index.haml
+++ b/src/app/views/users/index.haml
@@ -29,7 +29,7 @@
-(a)users.each do |user|
%tr
%td
- %input{:name => "user_checkbox", :type =>
"checkbox",
:value => user.id, :id => "user_checkbox_#{user.id}" }
+ %input{:name => "user_checkbox", :type =>
"checkbox",
:value => user.id, :id => "user_checkbox_#{user.id}", :onchange =>
"update_link(#{user.id})"}
%td= link_to user.login, {:action => "edit", :id => user.id}
%td= user.last_name
%td= user.first_name
@@ -41,3 +41,17 @@
$(document).ready(function () {
$("input[type='checkbox']").buttonSensitivity().change();
});
+
+ function update_link(id)
+ {
+ var checkbox = document.getElementById('user_checkbox_' + id)
+ if(checkbox.checked)
+ {
+ var checkboxes = document.getElementsByName("user_checkbox")
+ for(var i = 0; i < checkboxes.length; i++)
+ {
+ checkboxes[i].checked = false
+ }
+ checkbox.checked = true
+ }
+ }
\ No newline at end of file
--
1.7.2.3
Why not to have it written in jQuery instead of plain Javascript?
-- Ladislav