Forum: Ruby on Rails Rails and Jquery

Posted by Barry (Guest)
on 2013-03-12 23:52
(Received via mailing list)
Hellow, I have such problem. So I have usual .js.erb template, which is
called from controller with format.js
This template is just for testing now, so only calls alert message, if 
some
links are clicked. I didn't modified default layout document.
The problem is that on first click nothing happens, than it alerts as 
many
times, as all links was clicked until this moment.
So 1st time click - zero alerts, 2 time click - 1 alert, 3 time click - 
2
alerts and so on.
The code of Jquery file is so simple, that definetely not the source of
problem.
May be some ideas?
Posted by Colin Law (Guest)
on 2013-03-14 20:46
(Received via mailing list)
On 12 March 2013 22:50, Barry <burmanz@mail.ru> wrote:
> Hellow, I have such problem. So I have usual .js.erb template, which is
> called from controller with format.js
> This template is just for testing now, so only calls alert message, if some
> links are clicked. I didn't modified default layout document.
> The problem is that on first click nothing happens, than it alerts as many
> times, as all links was clicked until this moment.
> So 1st time click - zero alerts, 2 time click - 1 alert, 3 time click - 2
> alerts and so on.
> The code of Jquery file is so simple, that definetely not the source of
> problem.

Well since the rest of the code is so simple it can't be that either,
I assume.  The obvious conclusion is that it is working correctly.

Have a look at the rails guide on debugging which will give you
techniques that you can use to debug the code.  The first thing to do
is to work out where it is failing so you can look in the log to see
what actions are being called at what points and you can debug the
data you are passing up to the view to see if that is ok.

Once you have worked out which bit of code is failing you will
probably see the problem, if not then come back and show us the code
that is failing (not the whole app, just the bit that is failing).

Colin
Posted by Robert Walker (robert4723)
on 2013-03-14 20:55
Colin Law wrote in post #1101662:
> Well since the rest of the code is so simple it can't be that either,
> I assume.  The obvious conclusion is that it is working correctly.
>
> Have a look at the rails guide on debugging which will give you
> techniques that you can use to debug the code.  The first thing to do
> is to work out where it is failing so you can look in the log to see
> what actions are being called at what points and you can debug the
> data you are passing up to the view to see if that is ok.
>
> Once you have worked out which bit of code is failing you will
> probably see the problem, if not then come back and show us the code
> that is failing (not the whole app, just the bit that is failing).
>
> Colin

@Colin, FYI: I'm pretty sure this is a duplicate of another thread, 
which has been resolved.
Posted by Colin Law (Guest)
on 2013-03-14 22:35
(Received via mailing list)
On 14 March 2013 19:55, Robert Walker <lists@ruby-forum.com> wrote:
>> Once you have worked out which bit of code is failing you will
>> probably see the problem, if not then come back and show us the code
>> that is failing (not the whole app, just the bit that is failing).
>>
>> Colin
>
> @Colin, FYI: I'm pretty sure this is a duplicate of another thread,
> which has been resolved.

OK, thanks.  I must have missed it.

Colin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.