Hallo Marcel,
du musst einfach nur eindeutige Funktionsnamen sicherstellen.
In diesem Beispiel JavaScript (das reine JavaScript Äquivalent der jQuery Funktion $.ready) wird immer nur die zweite der beiden Funktionen 'test' aufgerufen:
stackoverflow.com/questions/9899372/pure...ll-a-function-when-t
Code:
<script type="text/javascript">
(function() {
// Pure JavaScript equivalent of jQuery's $.ready()
console.log('console logged: document ready 1')
test();
})();
(function() {
// Pure JavaScript equivalent of jQuery's $.ready()
console.log('console logged: document ready 2')
test();
})();
function test() {console.log('console logged: function test1 called');}
function test() {console.log('console logged: function test2 called');}
</script>
Consolen-Output:
console logged: document ready 1
console logged: function test2 called
console logged: document ready 2
console logged: function test2 called
Und so funktioniert es:
Code:
<script type="text/javascript">
(function() {
// Pure JavaScript equivalent of jQuery's $.ready()
console.log('console logged: document ready 1')
test1();
})();
(function() {
// Pure JavaScript equivalent of jQuery's $.ready()
console.log('console logged: document ready 2')
test2();
})();
function test1() {console.log('console logged: function test1 called');}
function test2() {console.log('console logged: function test2 called');}
</script>
Consolen-Output:
console logged: document ready 1
console logged: function test1 called
console logged: document ready 2
console logged: function test2 called
Gruß, Ingmar