From: martyntaylor mtaylor@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 @@ -@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
----- mtaylor@redhat.com wrote:
From: martyntaylor mtaylor@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 @@ -@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
Does this apply OK? Does it work properly?
----- Original Message ----- From: "Ladislav Martincik" lmartinc@redhat.com To: mtaylor@redhat.com Cc: deltacloud-devel@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@redhat.com wrote:
From: martyntaylor mtaylor@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 @@ -@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
On Thu, 2010-10-21 at 06:45 -0400, Ladislav Martincik wrote:
----- mtaylor@redhat.com wrote:
From: martyntaylor mtaylor@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 @@ -@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?
I agree with Ladislav on this, but even more, this raised the issue that really we are trying to shoehorn radio button behavior into checkboxes. I created a ticket to switch everything over to radio buttons which Tomas is working on - this should obviate this bug.
-j
deltacloud-devel@lists.fedorahosted.org