Thread Perl + Bootstrap4: Tooltip Problem (18 answers)
Opened by Der-Niko2 at 2018-12-17 00:37

GwenDragon
 2018-12-17 10:15
#189402 #189402
User since
2005-01-17
14533 Artikel
Admin1
[Homepage]
user image
Du musst nicht auf Englisch schreiben, dies ist die deutsche Perl-Community und da dein Nick sich deutsch anhört, antworte ich dir mal auf Deutsch. ;)


Ich brauche schon die genaue Fehlermeldung in der Browserkonsole wegen deines Javascriptproblems! Bitte mit CODE-Button posten.

Zeile 6: nach Content-Type: muss ein Leerzeichen sein.

Zeile 5: Statt print <<OUT; besser print <<'OUT';.
print <<OUT; bedeutet eigentlich print <<"OUT"; und damit expandiert Perl alle Variablen (in dem Fall die mit $beginnen) in dem Multiline-Text.
Siehe https://perlmaven.com/here-documents

Teste mal aus was dein Programm in der Kommandozeile zeigt:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Content-type:text/html

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container mt-3">
<h3>Tooltip Example</h3>
<p>Tooltips must be initialized with jQuery: select the specified element and call the tooltip() method.</p>
<a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
</div>

<script>
0document).ready(function(){
0'[data-toggle="tooltip"]').tooltip();
});
</script>

</body>
</html>

Du siehst also, dass Perl dessen vermeintlich eigene Variable $( im script-Block expandiert hat! Perl kann nicht wissen, dass das $(…)-Konstrukt eine jQUery-Variable in JS ist.

Wenn du unbedingt print <<OUT; nehmen willst, solltest du alle $%@ maskieren und in dem Fall so:
Code: (dl )
1
2
\$(document).ready(function(){
\$('[data-toggle="tooltip"]').tooltip();

Last edited: 2018-12-17 11:17:09 +0100 (CET)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread Perl + Bootstrap4: Tooltip Problem