开发者

How to open in new tab when clicking JQuery auto complete search results?

开发者 https://www.devze.com 2023-02-05 23:17 出处:网络
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 disp

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;
});
0

精彩评论

暂无评论...
验证码 换一张
取 消