All geek questions in one place

    Prevent bootstrap loading by adding URL hash

    I applied scrollspy Bootstrap 3.0 as follows:

    <nav id="navProposalPreview"> <ul class="nav navbar-nav"> <li class="active"><a href="#previewTitlePage">Title Page</a></li> <li><a href="#previewDisplay">Display</a></li> <li><a href="#previewAddlServices">Additional Services</a></li> </ul> </nav> <div class="modal-body"> <div> <p id="previewTitlePage"></p> <div>Stuff</div> <p id="previewDisplay"></p> <div>Other stuff</div> <p id="previewAddlServices"></p> <div>Last stuff</div> </div> </div> 

    I initialize it as follows:

     $('.modal-body').scrollspy({ target: '#navProposalPreview', offset: 20 }); 

    It sets the active li , as expected, as you scroll, and also allows you to navigate sections using links. The problem is that when you click on the links, it will add a link to the url in the hash, for example. mysite.com/#previewDisplay. I do not want the url to be altered at all.

    I came across this before in tabs, which I suppose, and I forgot if I needed to set data-parent or add a click event as follows:

     $previewModal.find('#navProposalPreview a').on('click', function (e) { e.preventDefault(); return false; }); 

    Adding data-parent does not apply to scrollspy, for example, for tabs, and the click event above results in a link not being moved.

    Thanks in advance.

    +6
    twitter-bootstrap twitter-bootstrap-3 scrollspy
    im1dermike Jun 10 '14 at 16:14
    source share
    1 answer

    ok here it goes through bootstrap

     **"To keep URLs intact, use the data-target attribute instead of href="#"."** 

    like this

     data-target="#" 

    http://getbootstrap.com/javascript/#dropdowns

    here is a working example of a violin sorry for the confusion! data-target="#navbar" for the container where the binding is bound to

    +1
    nolawi petros Jun 10 '14 at 18:44
    source share

    Source: https://habr.com/ru/post/970634/

    More articles:

    • upload csv file to numpy and access columns by name - python
    • Why am I getting SQLCODE = -204, SQLSTATE = 42704 with DB2 LUW and WebSphere App Server? - java
    • No cached version of gradle - android
    • Get full stack trace from remote session - powershell
    • Why doesn't the AppBarButtons respond to Tapped events in Windows Phone 8.1 RT Universal apps? - win-universal-app
    • Contour differences between C ++ and Python - c ++
    • How to connect a debugger to the mstest command line - debugging
    • sql server - how to find rows with spaces in a column - c #
    • Limit objects in a collection from serialization based on User - c #
    • How to use BaseGameActivity.getApiClient () in multiple actions? - android

    All Articles

    Geek Questions | 2019