repeated methods in rjs

Is there a way to use any kind of helper or something if you do the
same thing on every rjs call? Like render a flash box div?

Chris Habgood wrote:

Is there a way to use any kind of helper or something if you do the
same thing on every rjs call? Like render a flash box div?

Why not write JavaScript directly in unobtrusive style, and call the
appropriate function as necessary?

Best,

It is a full ajax site. flash gets rendered on every call, nothing
in it if it is empty anyway.

Please quote when replying -- otherwise we don't know what you're
responding to.

Chris Habgood wrote:

It is a full ajax site. flash gets rendered on every call, nothing
in it if it is empty anyway.

So what? That's irrelevant to the advice I gave, isn't it?

Best,

Ok, how would I implement the manual JS version to get called
automatically on every rjs render?

For the second time: please quote when replying!

Chris Habgood wrote:

Ok, how would I implement the manual JS version to get called
automatically on every rjs render?

Why do you need RJS?

Best,

" Why do you need RJS? "

It is an ajax call

Chris Habgood wrote:

" Why do you need RJS? "

It is an ajax call

That doesn't require RJS.

Best,

“That doesn’t require RJS.”

Ok, this is an early build out I do not want updates in the controller ase may have additional stuff in the future and i do not want the controller cluttered up.

Chris Habgood wrote:

"That doesn't require RJS."

Ok, this is an early build out I do not want updates in the controller
ase
may have additional stuff in the future and i do not want the controller
cluttered up.

On Thu, Feb 11, 2010 at 12:27 PM, Marnen Laibow-Koser

Who said anything about cluttering the controller? RJS serves no useful
purpose as far as I can see (I could be wrong).

Anyway, you're being so vague about the structure of your app that it's
not possible to help. Try providing more information.

Best,

Why the war on RJS? It's been working great for me since Rails 0.8.

Serves no useful purpose? The one I wrote a few minutes ago seems
damn useful to me and my app. The 98349837498 RJS files I've written
previously also seem very useful.

I think what's useless here is most of what you post.

“Anyway, you’re being so vague about the structure of your app that it’s
not possible to help. Try providing more information.”

It is a full ajax app. Meaning, the only real page refreshes are when logging in and out. We have a ton of ajax calls. I was just trying to DRY up the rjs files if we load the flash box on every call.

Greg Donald wrote:

Chris Habgood wrote:

" Why do you need RJS? "

It is an ajax call

That doesn't require RJS.

Why the war on RJS?

What war? It doesn't seem to be serving the OP well.

It's been working great for me since Rails 0.8.

How do you keep the generated JavaScript out of your HTML?

--
Greg Donald
destiney.com | gregdonald.com

Best,

Greg Donald wrote:

Who said anything about cluttering the controller? �RJS serves no useful
purpose as far as I can see (I could be wrong).

Serves no useful purpose? The one I wrote a few minutes ago seems
damn useful to me and my app.

Let's see it! I'm always willing to learn.

The 98349837498 RJS files I've written
previously also seem very useful.

You've lived for millennia and written an RJS file every second?
Fascinating!

I think what's useless here is most of what you post.

Personal attacks do not belong on this list, or any other.

--
Greg Donald
destiney.com | gregdonald.com

Best,

Why the war on RJS?

What war? It doesn't seem to be serving the OP well.

And since by your own admission you know little to nothing about RJS
templates, what makes you an authority to dismiss them as "useless"?

It's been working great for me since Rails 0.8.

How do you keep the generated JavaScript out of your HTML?

Partials.

Well someone had to say something, I'm sick of reading the crap you post.

Greg Donald wrote:

Why the war on RJS?

What war? �It doesn't seem to be serving the OP well.

And since by your own admission you know little to nothing about RJS
templates, what makes you an authority to dismiss them as "useless"?

I don't claim to be one. I'm no RJS expert, and I do plan to look at
RJS in more detail the next time I need significant amounts of
JavaScript in a project. But I *am* an expert JavaScript programmer,
and I really do not see the advantage of *not* writing my JavaScript
directly.

Why do you prefer RJS to writing JavaScript?

�It's been working great for me since Rails 0.8.

How do you keep the generated JavaScript out of your HTML?

Partials.

Wouldn't that still put the JavaScript into your HTML files?

--
Greg Donald
destiney.com | gregdonald.com

Best,

Why do you prefer RJS to writing JavaScript?

RJS is a template rendering system that also happens to execute JS. I
do not prefer one over the other, it's apples and oranges.

Controller action:

def get_user
  if request.xhr?
    @user = User.find( params[:id] )
  end
end

get_user.rjs:

if @user
  page.replace_html 'user_tab', :partial => 'user/user_form'
  page << "$j( '#user_tab' ).fadeIn('slow');"
end

How do you keep the generated JavaScript out of your HTML?

Partials.

Wouldn't that still put the JavaScript into your HTML files?

Yup.

Greg Donald wrote:

Personal attacks do not belong on this list, or any other.

Well someone had to say something, I'm sick of reading the crap you
post.

Then don't read it and don't make attacks like this. I'm sure everyone
has posters they feel this way about -- I know I do -- but we don't say
that kind of thing.

--
Greg Donald
destiney.com | gregdonald.com

Best,