Sie sind nicht angemeldet.

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

1

Donnerstag, 12. Juli 2012, 17:15

Retrieving clicked hotspot[name] from XML via JavaScript

I can't get this to work properly. My alert message keeps reading out -1 for some reason.

XML

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<hotspot 
name="hs"
url="hs.png"
keep="false"
ath="-15" atv="-23"
onclick="openmodal();"
/>

<action name="openmodal">
looktohotspot(get(name), 25, smooth(800,800,800));
js(modalopen);
set(plugin[modalclose].visible, true);
</action>


JS

Quellcode

1
2
3
4
function modalopen() { 
var hotspotID = krpano().get('hotspot[get(name)].name');
alert(hotspotID);
}



Any other better (or correct) ways to pull the hotspot name through? *blink* Thanks!
Say "Hi!" on twitter

Zephyr

Profi

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

2

Donnerstag, 12. Juli 2012, 18:13

Hi, can't you just do:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<hotspot 
name="hs"
url="hs.png"
keep="false"
ath="-15" atv="-23"
onclick="openmodal();"
/>

<action name="openmodal">
looktohotspot(get(name), 25, smooth(800,800,800));
js(modalopen(get(name)));
set(plugin[modalclose].visible, true);
</action>


Quellcode

1
2
3
function modalopen(hotspotID) { 
alert(hotspotID);
}

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

3

Donnerstag, 12. Juli 2012, 18:16

Well I need the name of the hotspot to become my JS var hotspotID. Trying to set hotspotID with the current hotspot[name].
Say "Hi!" on twitter

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

4

Donnerstag, 12. Juli 2012, 18:25

oops double posted
Say "Hi!" on twitter

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

5

Donnerstag, 12. Juli 2012, 18:25

If I try below, it comes up as undefined

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<hotspot 
name="hs"
url="hs.png"
keep="false"
ath="-15" atv="-23"
onclick="openmodal();"
/>

<action name="openmodal">
looktohotspot(get(name), 25, smooth(800,800,800));
js(modalopen(get(name)));
set(plugin[modalclose].visible, true);
</action>



js

Quellcode

1
2
3
function modalopen(hotspotID) { 
alert(hotspotID);
}
Say "Hi!" on twitter

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

6

Donnerstag, 12. Juli 2012, 18:32

Oh, wait. Now it's working! Perhaps I didn't refresh. Thanks Zephyr! *thumbup*
Say "Hi!" on twitter