When i use live search show an extra output format

10 views
Skip to first unread message

Fernando Jesus

unread,
Jun 4, 2013, 12:09:08 PM6/4/13
to rubyonra...@googlegroups.com
Hi guys, i've been looking for some "light" for this problem, but
honestly i dont know where i can find some information about this.

I'm using ajax for a live search, so everything works fine.

View:


<form id="live-search-form" method="get" action="<%= search_path %>">
<input id="big-search-box" name="q" type="text" autocomplete="off"/>
</form>

<div id="live-search-results"></div>


Controller:

def live_search

@lafnuevas = Lafnueva.search params[:q], :page => params[:page],
:per_page => 1000
render :partial => 'filtrado'

end


Application.js:


$(document).ready(function(){
$('#big-search-box').bind('keyup',function() {

var form = $('#live-search-form'); // grab the form wrapping the
search bar.
var url = '/lafnuevas/live_search'; // live_search action.
var formData = form.serialize(); // grab the data in the form


$.get(url, formData, function(html) { // perform an AJAX get
$('#live-search-results').html(html); // replace the "results"
div with the results

});

});

});


But when i display the information i get the extra content that is the
result of my query:

[#<Lafnueva id: 80091, captura: "71", fechac: "1997-02-04 00:00:00",
titulo1: "L'ATLAS CURIEUX OU LE MONDE ... / DRESSé ET DEDIé..."

And after that i have my partial without problem.

Somebody can help me for dont display the extra content i've been
looking for the problem and perhaps everything for solve the problem is
in this line in application.js :
$('#live-search-results').html(html); // replace the "results"
div with the results


but the other options dont work fine (val,text), and when i inspect the
element the extra content appear between quotes (").

Thanks in advance.

--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages