jquery radio buttons

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

jquery radio buttons

fugee ohu
Can I treat radio buttons the same as other fields in my form for the purposes of jquery script
Can I use 
$("#example").change(function(e) 
  if (e.target.value=='Yes') 
  ...

Or do I have to use a different method?

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

Robby O'Connor
http://api.jquery.com/checkbox-selector/

On 04/02/2017 01:24 AM, fugee ohu wrote:

> Can I treat radio buttons the same as other fields in my form for the
> purposes of jquery script
> Can I use
> $("#example").change(function(e)
>   if (e.target.value=='Yes')
>   ...
>
> Or do I have to use a different method?
>
> --
> 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 [hidden email]
> <mailto:[hidden email]>.
> To post to this group, send email to [hidden email]
> <mailto:[hidden email]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8fb21d9c-d5b5-76f6-3397-421c297bc390%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

Robby O'Connor
Looks like this answers your question: http://stackoverflow.com/a/7031408

On 04/02/2017 06:25 AM, Robby O'Connor wrote:

> http://api.jquery.com/checkbox-selector/
>
> On 04/02/2017 01:24 AM, fugee ohu wrote:
>> Can I treat radio buttons the same as other fields in my form for the
>> purposes of jquery script
>> Can I use
>> $("#example").change(function(e)
>>   if (e.target.value=='Yes')
>>   ...
>>
>> Or do I have to use a different method?
>>
>> --
>> 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 [hidden email]
>> <mailto:[hidden email]>.
>> To post to this group, send email to [hidden email]
>> <mailto:[hidden email]>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b13bc31f-a7cd-069e-4783-beb951ba4e45%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

fugee ohu


On Sunday, April 2, 2017 at 6:27:03 AM UTC-4, Robert O'Connor wrote:
Looks like this answers your question: <a href="http://stackoverflow.com/a/7031408" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fa%2F7031408\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHskobORvS8wB7AZB9uD45nJo2n7A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fa%2F7031408\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHskobORvS8wB7AZB9uD45nJo2n7A&#39;;return true;">http://stackoverflow.com/a/7031408

On 04/02/2017 06:25 AM, Robby O'Connor wrote:

> <a href="http://api.jquery.com/checkbox-selector/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fapi.jquery.com%2Fcheckbox-selector%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEssVLXxneCuQuINDctENMK1FJbiA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fapi.jquery.com%2Fcheckbox-selector%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEssVLXxneCuQuINDctENMK1FJbiA&#39;;return true;">http://api.jquery.com/checkbox-selector/
>
> On 04/02/2017 01:24 AM, fugee ohu wrote:
>> Can I treat radio buttons the same as other fields in my form for the
>> purposes of jquery script
>> Can I use
>> $("#example").change(function(e)
>>   if (e.target.value=='Yes')
>>   ...
>>
>> Or do I have to use a different method?
>>
>> --
>> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="swjlujSnAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-ta...@googlegroups.com
>> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="swjlujSnAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-talk+unsubscribe@...>.
>> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="swjlujSnAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com
>> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="swjlujSnAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com>.
>> To view this discussion on the web visit
>> <a href="https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com
>> <<a href="https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/0b70c901-972e-499b-8921-ac9e1e5ced54%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
 

  This isn't the place to post links to other forums Answer the question or don't 
 

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4d086928-ffcb-470f-8b57-db4fbe1523e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

Colin Law
On 2 April 2017 at 14:24, fugee ohu <[hidden email]> wrote:

  This isn't the place to post links to other forums Answer the question or don't 

You would be more likely to get helpful answers if you ever said thanks when people here do help you.
For example your post with subject "conditional validatiobs" (whatever that means) on 29th March.

Colin

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtvmcJg6woroJQ3h64zMOYUc_2pnUcnyZoEfY2Yr_z11A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

James Jelinek (shakycode)
Agreed. Politeness and kindness goes a long way. 

Sent from my iPhone

On Apr 2, 2017, at 8:48 AM, Colin Law <[hidden email]> wrote:

On 2 April 2017 at 14:24, fugee ohu <[hidden email]> wrote:

  This isn't the place to post links to other forums Answer the question or don't 

You would be more likely to get helpful answers if you ever said thanks when people here do help you.
For example your post with subject "conditional validatiobs" (whatever that means) on 29th March.

Colin

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtvmcJg6woroJQ3h64zMOYUc_2pnUcnyZoEfY2Yr_z11A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/D1D20ABB-6C5B-433F-9E08-51716949B7AA%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

fugee ohu
In reply to this post by Colin Law


On Sunday, April 2, 2017 at 9:49:21 AM UTC-4, Colin Law wrote:
On 2 April 2017 at 14:24, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Dpsfwj6yAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:

  This isn't the place to post links to other forums Answer the question or don't 

You would be more likely to get helpful answers if you ever said thanks when people here do help you.
For example your post with subject "conditional validatiobs" (whatever that means) on 29th March.

Colin


Then thanks and sorry and sorry to James too I didn't mean  to be unpolite or ungracious although we need our forum we can't just link to answers on others 
To answer my own question A: Yes; The reason it didn't work is because rails actionview radio button helper creates radio buttons which successfully relay info on form submission but actually the html it renders leaves out a foward slash for the closing greater than sign > should be /> so it causes jquery not to pick it up properly; maybe, that's how i fixed it i think

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f9e6e15d-add1-4c6d-ba59-ba7042fe7f68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

fugee ohu
In reply to this post by Colin Law


On Sunday, April 2, 2017 at 9:49:21 AM UTC-4, Colin Law wrote:
On 2 April 2017 at 14:24, fugee ohu <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Dpsfwj6yAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">fuge...@...> wrote:

  This isn't the place to post links to other forums Answer the question or don't 

You would be more likely to get helpful answers if you ever said thanks when people here do help you.
For example your post with subject "conditional validatiobs" (whatever that means) on 29th March.

Colin


I do delete my invalid unanswered questions although there's a lag

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b93f892d-3ccc-4f4d-b12c-829e29e52217%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

Colin Law
On 2 April 2017 at 15:58, fugee ohu <[hidden email]> wrote:


On Sunday, April 2, 2017 at 9:49:21 AM UTC-4, Colin Law wrote:
On 2 April 2017 at 14:24, fugee ohu <[hidden email]> wrote:

  This isn't the place to post links to other forums Answer the question or don't 

You would be more likely to get helpful answers if you ever said thanks when people here do help you.
For example your post with subject "conditional validatiobs" (whatever that means) on 29th March.

Colin


I do delete my invalid unanswered questions although there's a lag

No you don't, they still appear in my inbox. It is impossible for you to deleted them from there.
Also there is no reason not to reply by pointing to an answer that already exists out on the web. Whether it is in a reply on another support group or on a web page somewhere or a reference to some docs. Do you suggest that we copy and paste the answer here, so filling the web up with duplicate data?  It is a lot easier for you to click on a link than it is for someone else to copy/paste a reply from elsewhere. You should be grateful that he/she took the time to look it up for you.

Colin
 

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b93f892d-3ccc-4f4d-b12c-829e29e52217%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLuLGgpp4OMzX2G3ycnHRqwJvF7VUuDHXfsqyCLF60NRaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: jquery radio buttons

Walter Lee Davis
In reply to this post by fugee ohu

> On Apr 2, 2017, at 10:55 AM, fugee ohu <[hidden email]> wrote:
>
> The reason it didn't work is because rails actionview radio button helper creates radio buttons which successfully relay info on form submission but actually the html it renders leaves out a foward slash for the closing greater than sign > should be /> so it causes jquery not to pick it up properly; maybe, that's how i fixed it i think


Rails since v3 has used HTML5 for its templating language by default. If you haven't changed anything, that's the expectation. HTML5 allows but does not require the "self-closed" tags of XHTML -- <hr /> and <hr> are equivalent, IOW.

In my (admittedly limited) experience with jQuery (I have far more experience with Prototype), I doubt very much that the trailing slash had anything to do with the matcher. Both Prototype and jQuery use the Sizzle matcher, and it's extremely good. More likely, you may have inadvertently written invalid HTML (regardless of level) including multiple items with the same ID attribute. It's always a good first step when diagnosing JavaScript weirdness to view source in a browser, copy it, and paste it into https://validator.w3.org to see if there are any obvious errors. jQuery won't complain if you use the same ID twice (or more) in a page, but it will do unpredictable things when you try to access an attribute or value.

Finally, the Rails checkbox / radio button helper provides an empty same-name hidden variable for each item that needs one, since in all HTML/CGI interfaces, the lack of a checkbox does not send a foo=false in a form post, it just does not send foo at all. Thus you will see this construction in your radio buttons:

        <input type="hidden" name="foo" value="" />
        <input type="radio" name="foo" value="bar" />
        <input type="radio" name="foo" value="baz" />

This means that the foo key will be present in all of your submissions, regardless if any of the options are checked or not. This is of much more importance in checkboxes than radio buttons, since without it, there would be no way to "un-check" a checkbox using an HTML form.

Walter

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0123F25C-003D-4883-A63A-3123026CB71F%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.