Now I want to do that in pure Rails 3 code with a check_box_tag, but I
don't know where to put my jquery code. I already watched the Railcast
episode about jquery, but that didn't helped me at all!
function(){
class_to_show = $(this).attr("id");
switch(class_to_show){
case 'show1':
$(".show1").show();
$(".show2").hide();
break;
case 'show2':
$(".show1").hide();
$(".show2").show();
break;
default
$(".show1").show();
$(".show2").show();
}
}));
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Check to be absolutely certain you are using jQuery rather than Prototype. While most of this code will work fine with either, the basic accessor (shortcut for findElementById) in Prototype is $('theId'), while jQuery prefers $('#theId'). Also, attr(key) in jQuery is readAttribute(key) in Prototype.
Walter
You need a colon after the word default in any switch statement, in any language I know that uses it.
Walter
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> I'm sorry for the typo, I have just fixed the code as follow:
>
> (function() {
> $("#filters input:checkbox").click(
> function(){
> class_to_show = $(this).attr("id");
> switch(class_to_show){
> case 'show1':
> $(".show1").show();
> $(".show2").hide();
> break;
> case 'show2':
> $(".show1").hide();
> $(".show2").show();
> break;
> default:
> $(".show1").show();
> $(".show2").show();
> }
> })});
And what happens now? What does Firebug tell you when it runs?
Walter
On Oct 24, 2011, at 10:50 AM, Roy Situmorang wrote:
> I'm sorry for the typo, I have just fixed the code as follow:
>
> (function() {
> $("#filters input:checkbox").click(
> function(){
> class_to_show = $(this).attr("id");
> switch(class_to_show){
> case 'show1':
> $(".show1").show();
> $(".show2").hide();
> break;
> case 'show2':
> $(".show1").hide();
> $(".show2").show();
> break;
> default:
> $(".show1").show();
> $(".show2").show();
> }
> })});
Ah, I found my mistake!!!
I was just only adding JQuery in my view with <%=
javascript_include_tag "http://code.jquery.com/jquery-latest.js" %>,
but not in my application.html.erb. That means that the code in the
application.js had propably no JQuery access!
My problem now is that my other normal Rails Java Helpers (see
below )are not working anymore as intended!
<%= button_to 'Destroy', product, :confirm => 'Are you sure?', :method
=> :delete %>
That one is wotking, but there is no confirm pop up!!!!
I read something about JRails. Is that an option or is there another
way???
google to your Gemfile and at this