How to open in new tab when clicking JQuery auto complete search results?
I am using JQuery auto completer plugin along with Rails 3. I have a search bar which shows different site开发者_开发技巧 names. on click this auto complete results, corresponding sites page gets displayed.
My issues is I want to get the sites url opened in new tab. How is this possible.
sites.each do |site|
suggestions << {:text => "site: #{site.name}", :url => url}
end
render :json => suggestions
This has nothing to do with Rails. You could use
window.open(url)
to handle this via Javascript, since you're already using jQuery.
Example for a link:
$('a').click(function(){
window.open(this.href);
return false;
});
精彩评论