hello,
i will simple check/uncheck all checkboxes.
but my code doen´t work ;(
function checked(element)
{
element.checked = !element.checked;
return element;
}
function select()
{
var checkboxes =
$(''articles'').getInputs(''checkbox'');
checkboxes.invoke(''checked''); not working
}
but this work:
function select()
{
var checkboxes =
$(''articles'').getInputs(''checkbox'');
for (var i = 0;i<checkboxes.length;i++)
{
checkboxes[i].checked = !checkboxes[i].checked;
}
}
is there a simple way to do this? The Form.Element has no function
check ;(
thanks for your help. greetings
Gordon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
gimler wrote:> hello, > > i will simple check/uncheck all checkboxes. > > but my code doen´t work ;( > function checked(element) > { > element.checked = !element.checked; > return element; > } > function select() > { > var checkboxes = $(''articles'').getInputs(''checkbox''); > checkboxes.invoke(''checked''); not working > }I think you''re not understanding what invoke() does. It invokes the same "method" on each object in the Enumerable. Your checked() function is not a method on a checkbox HTML form element. It''s just a function. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The reason the first block of code doesn''t work is that invoke() works
on methods of an object. Because your checked() function isn''t a
method
of the Element object, invoke isn''t what you want. This should work,
though:
function checked(element) {
element.checked = !element.checked;
return element;
}
$("article").getInputs("checkbox").each(function(element) {
checked(element) });
-- Dash --
gimler wrote:> hello,
>
> i will simple check/uncheck all checkboxes.
>
> but my code doen´t work ;(
> function checked(element)
> {
> element.checked = !element.checked;
> return element;
> }
> function select()
> {
> var checkboxes =
$(''articles'').getInputs(''checkbox'');
> checkboxes.invoke(''checked''); not working
> }
>
> but this work:
> function select()
> {
> var checkboxes =
$(''articles'').getInputs(''checkbox'');
> for (var i = 0;i<checkboxes.length;i++)
> {
> checkboxes[i].checked = !checkboxes[i].checked;
> }
> }
>
> is there a simple way to do this? The Form.Element has no function
> check ;(
>
> thanks for your help. greetings
> Gordon
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
David Dashifen Kees wrote:> The reason the first block of code doesn''t work is that invoke() works > on methods of an object. Because your checked() function isn''t a method > of the Element object, invoke isn''t what you want. This should work, > though: > > function checked(element) { > element.checked = !element.checked; > return element; > } > > $("article").getInputs("checkbox").each(function(element) { > checked(element) }); > >Oops! Even simpler.... $("article").getInputs("checkbox").each(checked); Yes, what you wanted was exactly each() not invoke(). Also, your checked function need not return anything. --Ken Snyder --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
and yet shorter: $$(''#article input:checked'')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
hmm its not working.
uncaught exception: Parse error in selector: '':checked''
greetings
Gordon
-----Ursprüngliche Nachricht-----
Von: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Gesendet: 16.05.07 17:36:22
An: "Ruby on Rails: Spinoffs"
<rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: [Rails-spinoffs] Re: invoke checked
and yet shorter: $$(''#article input:checked'')
_______________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---