开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜