samedi 9 janvier 2016

Bootstrap tooltip/popover not showing properly

Vote count: 0

I'm using Angular 2 to build my web application. When I try to put a tooltip or popover on an image or button, I get the default-looking tooltip instead of the bootstrap one.

I've tried the basic W3Schools examples and did everything as shown, yet it doesn't work.

I believe my problem lies with the correct imports of the bootstrap.js or jQuery, but other bootstrap items like buttons etc. do work properly.

(I use nodejs to install the necessary files/dependencies -> npm install npm install bootstrap npm install jquery)

index.html

<html>
<head>
    <base href="/"><!--Without this tag, the browser may not be be able to load resources (images, css, scripts) when "deep linking" into the app. Bad things could happen when someone pastes an application link into the browser's address bar or clicks such a link in an email link. -->
    <title>Factory</title>
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="/css/styles.css">

    <script src="node_modules/jquery/dist/jquery.js"></script>
    <script src="node_modules/jquery/dist/jquery.min.js"></script>

    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/angular2/bundles/router.dev.js"></script>
    <script src="node_modules/angular2/bundles/http.dev.js"></script>

    <link rel="stylesheet" href="http://ift.tt/1RrshYi">
    <script src="http://ift.tt/1LdO4RA"></script>
    <script src="http://ift.tt/1D8Hvux"></script>

    <script src="node_modules/bootstrap/js/tooltip.js"></script>

    <script>
        System.config({
            packages: {
                app: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            }
        });
        System.import('app/boot')
                .then(null, console.error.bind(console));
    </script>
</head>
<body>
    <my-app></my-app>
</body>
</html>

page-with-tooltip(.ts)

import {Component} from "angular2/core";
import ... from ...;
import ... from ...;
...

@Component({
    template: `
<div *ngIf="hall" class="container">
    <h2>Detail van hal <small>{{hall.name}}</small></h2>
    <div class="container">
        <div class="hall-box-single">
            <div class="hall-box"
                [style.width]="hall.areaWidth*4"
                [style.height]="hall.areaHeight*4">
                <div class="image-container">
                <div *ngFor="#item of hall.items">
                    <a data-toggle="tooltip" data-toggle="popover" title="Popover title" data-content="Right?">
                    <img [src]="item.image"
                         [style.left]="item.posX"
                         [style.top]="item.posY"/>
                     </a>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        $('[data-toggle="popover"]').popover();
    });
</script>
`})

export class HallDetailComponent implements OnInit {
    ...
}

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Bootstrap tooltip/popover not showing properly

Aucun commentaire:

Enregistrer un commentaire