Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
erb and js question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Derek Smith  
View profile  
 More options Nov 12, 8:11 pm
Newsgroups: comp.lang.ruby
From: Derek Smith <derekbellnersm...@yahoo.com>
Date: Fri, 13 Nov 2009 10:11:58 +0900
Local: Thurs, Nov 12 2009 8:11 pm
Subject: erb and js question
Hi All,

I did some looking around on google and found a fix for setting the
default location of the cursor on a page.  The fix is mentioned here:

http://techsupt.winbatch.com/TS/T000002021F19.html

So my goal is to use Javascript, and place the the focus on one of the
boxes. The focus would mean that the typing cursor would be in a certain
box, but not the mouse cursor.

Here is my code:

cat login.html.erb
<!-- Begin Login Bar -->
<div id="login">
  <% form_tag :action => 'login' do %>
    <br />
    <label for='username'>Username:</label>
    <%= text_field_tag 'username' %>
    <label for='password'>Password:</label>
    <%= password_field_tag 'password' %>
    <%= image_submit_tag 'login.png' %>
    <br />
    <br />
  <% end %>
</div>
<!-- End Login Bar -->

Yet I am still unsure how to integrate this code, maybe just the JS
block?

thank you!
--
Posted via http://www.ruby-forum.com/.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Stephens  
View profile  
 More options Nov 13, 2:40 am
Newsgroups: comp.lang.ruby
From: Mike Stephens <rub...@recitel.net>
Date: Fri, 13 Nov 2009 16:40:42 +0900
Local: Fri, Nov 13 2009 2:40 am
Subject: Re: erb and js question
This looks like a JavaScript question. I recommend this forum :

http://w3schools.invisionzone.com/

I suggest you need the focus () function called by the onload event.
--
Posted via http://www.ruby-forum.com/.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Candler  
View profile  
 More options Nov 16, 5:56 am
Newsgroups: comp.lang.ruby
From: Brian Candler <b.cand...@pobox.com>
Date: Mon, 16 Nov 2009 19:56:14 +0900
Local: Mon, Nov 16 2009 5:56 am
Subject: Re: erb and js question

This isn't really a Ruby question, but briefly: you can emit a

<script language='javascript'>
  ...
</script>

which does what you want. However:

1. You want this to happen when the page has finished loading, so write
it to be triggered on the onload event.

2. It's cleaner to put it in the <HEAD> of your document, which could be
in the layout or using content_for :head

3. It's cleaner to put it in a separate Javascript file, e.g.
public/javascripts/focus_user.js, and then all you need is:

  <%= javascript_include_tag 'focus_user' %>

This sort of stuff is wonderfully easy to do using jQuery, and I
recommend it strongly. All you would need is:

jQuery( function($) {
  $('#username').focus();

});

--
Posted via http://www.ruby-forum.com/.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google