简体   繁体   中英

URL link wont work in backbone

I have a project done in backbone and I have one problem regarding basic links on the page , when I click on the link url has been copied to existing url and it wont lead to defined address , for example

in template I have link : <a href="http://www.google.com" class="google_link">google.com</a>

and in backbone I have this event : ' click .google_link' : 'google_link'

and function :

google_link: function(e) {

                $el = $(e.currentTarget);
                var link = $el.attr('href');
                Backbone.history.navigate(link, {trigger: true});

            },

and when I click on link i get address like this

http:// localhost:8888/backboneApp/#http://google.com

I know this is not right way but can anyone tell me how to handle static links to do normal stuff ?

EDIT without events its doing the same thing , just paste url to adress and nothing happens

I don't think you need to handle the external URLs. It should automatically be take care. Just try removing the events, it should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM