Autor |
Beitrag |
Marco D.
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Mo 13.08.07 14:11
Ich habe von einer JS-Klasse eine Objektinstanz. Ich möchte darin einem div ein OnClick-Event zuweisen. Die zugehörige Routine soll eine Funktion dieser Objektinstanz sein. Wenn die Instanz nun "tb" heißt, soll dort stehen:
Quelltext 1:
| <div onClick='tb.SetPosition(4)'> |
Wie kriege ich nun den Namen der Instanz (tb) heraus?
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
BenBE
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Mo 13.08.07 18:55
this.id
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
Marco D.
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Di 14.08.07 08:33
Wenn ich im Konstruktor
Quelltext
schreibe, gibt er mir {b]undefined[/b] aus.
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Regan
Beiträge: 2157
Erhaltene Danke: 72
Java (Eclipse), Python (Sublimetext 3)
|
Verfasst: Di 14.08.07 22:54
Wie wäre es, wenn du dem ganzen noch eine id verpasst!?
|
|
Marco D.
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Mi 15.08.07 08:10
Regan hat folgendes geschrieben: | Wie wäre es, wenn du dem ganzen noch eine id verpasst!? |
Wie jetzt?
Es sah nach BenBe's Antwort so aus, als ob in der Property id von dem Bezeichner this der Name der Objektinstanz enthalten ist. Muss ich das dann noch selber belegen?
Als Workaround habe ich es nun so gemacht, dass ich den Namen der Instanz als Zeichenkette im Konstruktor übergebe und in this.instance_name abspeichere. Damit geht es jedenfalls.
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
|