H
H
Happymalina2015-12-24 11:26:30
JavaScript
Happymalina, 2015-12-24 11:26:30

When you click on the tab name, the contents of the tab open, but the whole block jumps to the top of the viewport, how to fix it?

Hey!! The site has two blocks that are made through bootstrap tabs. The first block works fine, but in the second, when you click on the tab header, that is, everything switches to the link, but the entire block is thrown up the viewport, as if there was an anchor. Thought it was standard

$('#myTabs a').click(function (e) {
  e.preventDefault()
  $(this).tab('show')
})
will solve the problem. But it didn't help. Here is a resource - sovetandreevka.ru, right on the main news tab, posts are displayed on the right. Please tell me, the solution seems very simple, but maybe not obvious to me.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
romy4, 2015-12-24
@romy4

there seems to be a solution, but fixing it for free is somehow too low

T
tigra, 2015-12-24
@tigroid3

it's simple, at the end of the function write return false;
then do something like this.
insert the id of your block not into the link itself, but into some attribute.
and when clicking on any link, make active the news block with the id specified in the attribute of the specific link

$('.last-posts_list a').click(function () {
       var page = "#"+$(this).attr("id-page");
       $(page).addClass("active");
return false;
});

C
coderisimo, 2015-12-24
@coderisimo

the output of posts (on the right) does not respond to clicks at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question