Use path() method to genrate url in view && clean JS code