Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Funkcja nie jest funkcją.
MeGusta
post
Post #1





Grupa: Zarejestrowani
Postów: 155
Pomógł: 0
Dołączył: 6.07.2015

Ostrzeżenie: (10%)
X----


Witam,
Czemu pluje mi, że funkcja nie jest funkcją? Dodam, że jeśli umieszczę jej wywołanie poza forEach normalnie działa.

  1.  
  2. this.drawInventory = function(item)
  3. {
  4. document.getElementById('player_inv').innerHTML += item;
  5. return false;
  6. };
  7.  
  8. this.inventory.forEach(function(item) {
  9. this.drawInventory(item);
  10. });


Błąd:
Uncaught TypeError: this.drawInventory is not a function
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
markuz
post
Post #2





Grupa: Zarejestrowani
Postów: 1 240
Pomógł: 278
Dołączył: 11.03.2008

Ostrzeżenie: (0%)
-----


Ok. To wywał options z argumentu i przypisz domyślne wartości dla name i level tj. this.name = null; this.level = 0;
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 13:04