Hi guys,
I have a problem regarding doing some javascript effects with
Merb/jQuery. I'm porting an application from PHP.
I will show so code because i think it's better:
module Merb
module QuestionsHelper
def link_to_interested_user(question)
if session.user
interested = Interest.get(session.user.id, question.id)
if !interested.nil?
return 'interested!'
else
return link_to 'interested?', url(:user_interested, :id =>
question.id), :class => 'remote'
end
else
link_to 'interested?', url(:login)
end
end
end
end # Merb
.interested_mark{ :id => "mark_#{question.id}" }
= question.interested_users
= link_to_interested_user(question)
Ok, i want to do two things, first i want to show the 'indicator'
progress gif with jQuery.
$("#remote a").click(function() {
$("#indicator").show();
});
The second i want to do, is that when somebody hit the link for the
'interested?' it's make a ajax call to the action listed in the helper
method, so it can increase it's interested
for that user, this is the code for the action
def interested(id)
@question = Question.get(id)
raise NotFound unless @question
interest = Interest.new
interest.question = @question
interest.user = session.user
interest.save
render @question, :layout => false
end
And view for the action
= partial '/questions/intereted_user', @question
I'm reusing the same part above, or at least trying because the page
get's blank when i hit the 'interested?' link.
I set the render layout to false, because i just want to update the
block where the number resides, the problem is that as you can notice
the id for the block i want to update with the ajax call it's dynamic
"mark_#{question.id}", so how can i know which is in the jQuery call.
Thanks in advance.
--
Rafael George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---