Thanks for quick answer
> <script>
> var foo = new myclass {
> function open() {
> }}
but this was just to write to explain.
please don't look grammar itself.
My point was legal javascript object didn't invoked.
my real codes are something like below
function myclass() {
var open = function() {
}
}
var obj1 = new myclass;
and then in the link_to_remote :before=>'obj1.open();'
but obj1 is not defined error raised.
and could you explain how to deal with ajax request to implent that
insert javascript function before and after of redirect_to action?
thanks.
On 8월1일, 오후5시59분, Frederick Cheung <[email protected]> wrote:
> On Aug 1, 7:35 am, serenobs <[email protected]> wrote:
>
>
>
>
>
> > Hello.
>
> > I tried to invoke javascript in the controller, but I couldn't.
>
> > What I want to do is,
> > I'd like to verify passed parameters in the controller,
> > if parameters are not verified I'd like to invoke alert with error
> > message and back to othere function.
>
> > code will be like below
>
> > if verify? params[:value]
> > #call alert('value is not correct') <- how can I implement this
> > function?
> > redirect_to :action => 'index'
> > return
> > end
>
> > how can I implement that function?
>
> Unless you're dealing with an ajax request, you can't.
>
> > can I insert javascript function before and after of redirect_to
> > action?
>
> > and my second question is
>
> > <script>
> > var foo = new myclass {
> > function open() {
> > }}
>
> that doesn't look like legal javascript to me.
>
> Fred
>
>
>
>
>
> > </script>
> > <%= link_to_remote 'click me', :update=>'blah'. :url=>
> > {:action=>'something'}, :before=>'foo.open();' %>
>
> > When I clicked, javascript error occured, "foo is not defined"
> > if javascript is like "alert('blah');" it works.
> > Maybe local and global is the difference while I'm not sure.
>
> > anyway, how can I invoke javascript object that is not gloal object?- 원본
> > 텍스트 숨기기 -
>
> - 원본 텍스트 보기 -- 원본 텍스트 숨기기 -
>
> - 원본 텍스트 보기 -
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---