开发者

Go to particular div in rails 3

开发者 https://www.devze.com 2023-03-04 02:39 出处:网络
I have these two codes lines in subnativation. <%= link_to \"Basic In开发者_开发问答fo\", request.request_uri + \"#users_details\"%>

I have these two codes lines in subnativation.

 <%= link_to "Basic In开发者_开发问答fo", request.request_uri + "#users_details"%>
 <%= link_to "Photos", request.request_uri + "#users_photos"%>

==>

/users/1#users_details
/users/1#users_photos

Its not navigating to that particular Div.

PS: users_details and users_photo are Id's of two different div's


#users_details will navigate to <a name='users_details'></a> and #users_photos to <a href='users_photos'></a> somewhere in your HTML.

So put before your users_details div this: <a name='users_details'></a> and enjoy!


Try writing your links in a style that makes it more obvious where you are actually trying to go: something like <%= link_to "Basic Info", users_path(@user, :anchor => 'user_details') %>. This will create a link to the users#show page but also include the anchor to go to any block level element with the id of user_details.

0

精彩评论

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