Hi,
i have list of alphabets from A to Z .if i click on any one letter that should give me all the name starting with that corresponding letter from the database and should be displayed in the same page.
if i use each letter as a link(link_to) i cant display them in the same page.
if i use link_to_remote i am not able to get the params value of the letter i.e...Which letter i clicked.. if anyone know about this plz give me a solution.
3 4262
You could try Rails AJAX support to send the database results to a div within the same page. Or you could try using a partial.
- <%= javascript_include_tag "prototype" %>
-
<div class="element_links">
-
<% for char in 'A'..'Z' %>
-
<%= link_to_remote( "#{char}",
-
:update => "content",
-
:char => char,
-
:url =>{:action => :alp_search }) %> </li>
-
<% end %>
-
<div id="content"></div>
-
<p>
-
<ul>
This is my rhtml
and my controller is - def live_search
-
puts 'live_search'
-
@classifieds = Course.find(:all,:conditions => ["lower(course_name)like ?","%" + params[:search].downcase+ "%"])
-
puts @classifieds
-
if params['search'].to_s.size < 1
-
render :nothing => true
-
else
-
if @classifieds.size > 0
-
render :partial => 'display', :collection => @classifieds
-
else
-
render :text => "<li>No results found</li>", :layout => false
-
end
-
end
-
end
So as per the code if i click 'A' i should get all the courses which starts from 'A' from the database but am not able to get the params value of search.
In the place of link_to_remote if i use link i can get the correct result in the other page..but i want to display result in the same page..
is there is any way to do this...
Try adding content to your content div, such as - <div id="content">
-
<%= @content %>
-
</div>
-
Then, in your controller, set the content variable with the partial, like - def live_search
-
#...code...
-
@content = render_to_string(:partial => 'display', :collection => @classifieds)
-
-
render :update do |page|
-
page.replace_html 'content', @content
-
end
-
end
This should then update the div with your partial using your data collection.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alan J. Flavell |
last post by:
OK, today's email brought a comment from a reader, pointing out
something that I'd long since noticed myself but hadn't done anything
about it.
On my pages, I've got a first-letter style on paragraphs.
So far, so good: some of the paragraphs begin with a link, and
there are styles in the stylesheet for link, hover etc. The first
letter is still displayed as styled for the paragraph's first-letter.
|
by: Ian Richardson |
last post by:
At the moment I'm using a quicksort algorithm to sort a list of
countries in alphabetic order. This worked wonderfully until someone
came up with the Åland Islands... and this is at the end of the list.
I'm not sure it's supposed to be.
Now I could just alter my comparison so it ignores the top bit, but this
would then put it at the top of the list, even before Albania...
Alternatively, should I put Å after A?
|
by: George Thompson |
last post by:
How can I retrieve the first letter of data in a field within access?
(using access 2k?) is this a VB thing or is there an obvious solution?
|
by: Tim::.. |
last post by:
Hi...
I'm having a big problem with a datagrid that obtains data from 2 different
locations...
Active Directory and SQL Database
The data is inserted into a datatable and the sorted by a dataview...
however due to alphabetic paging and the postback ("I think") the contacts
from the SQL Database appear on ever page when you page through the datagrids
|
by: Xero |
last post by:
How do you get a specific letter from a word?
For example, in English, I would say:
Get the fifth letter from the word "Computer"
Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth letter)
How do you 'translate' this sentence into VB.net? Thanks!
--
Xero
| |
by: news |
last post by:
We're trying to make a search form, and are wanting to create links for
all the letters a person can click on and will bring up all entries
that start with that letter.
That part is easy:
.... WHERE field LIKE '$letter%'
But we'd like to also have one a person can click on for numbers and
punctuation.
Is there a built-in mySQL querey component where you can search for
entries in a column that start with a non-letter?
|
by: PulkitZery |
last post by:
Hi all,
I need some help in my project (VB.NET) here is what I need:
I need to convert Alphabetic number (a. b. c. d. …..) into the integers (for example a=1, b=2, c=3 and so on). Can anyone give me a function or point me to an article that explains how to convert these alphabetic number into the integers. Thanks very much in advance.
Jerry.
|
by: emre esirik(hacettepe computer science and enginee |
last post by:
I used a structer in this program.
typedef struct _guitar {
int serial; :serial of item at the guitar store
int price; :price of item at the guitar store
char builder; :builder of item at the guitar store
char type; :type of item at the guitar store
char model; :model of item at the guitar
store
}guitar;
|
by: crystal2005 |
last post by:
Hi guys,
Just like the title, i'm looking for the example of C program that translates an alphabetic phone number into numeric. The idea as the following output
Enter phone number: 1800-TEST-100
result: 1800-8378-100
so basically 2=ABC, 3=DEF, 4=GHI, . . . , 9 = WXYZ
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |