Problem passing multiple hotspot properties as parameters to js() action

  • I have run into a significant problem using the js() action on Internet Explorer 9 (IE9). I have created a <hotspot> with custom properties inside of a <scene>, and then I am using get() to retrieve them for use inside of a js() call. The problem is that only the first get(property) is being parsed properly: instead of passing the property's value, a string is being passed. This is only occurring in IE9 and below from what I can tell. I am testing inside a IE test virtual machine on Mac OS X. An example of the code is below.

    The scene xml markup: (the irrelevant markup has been omitted.

    Code
    <scene name="scene_sceneOne" title="sceneOne" >
      <view />
      <preview />
      <image></image>
      <!-- place your scene hotspots here -->
      <hotspot name="spot1" ath="0" atv="0" triggertype="type1" triggerid="id"
      onclick="js(handleTrigger( get(triggertype),get(triggerid) ));"
      />
    </scene>

    Corresponding javascript function:

    So, on all other browsers when this hotspot is clicked, "type1 id" will be logged to the console, however on IE9 and below "type1 get(triggerid)" will be logged instead.

    I am going to try and figure out a work around that uses only one hotspot property, perhaps holding an object, since it passes the first parameter fine. In the meantime, is there something wrong with the above implementation or is this in fact a bug? Thanks!
    [size=10]
    [size=10]

  • Okay, so I found a workaround. It's a bit strange, but perhaps it will shed some light on the bug.

    As I suspected, storing an object as the value on a single hotspot property is part of the solution, however this does not work alone. I assumed only using only one parameter would work since only the first one was being passed properly:
    XML markup:

    Code
    <scene name="scene_sceneOne" title="sceneOne" >
      <view />
      <preview />
      <image></image>
      <!-- place your scene hotspots here -->
      <hotspot name="spot1" ath="0" atv="0" triggerdata="{'type':'type1','id':'id'}"
      onclick="js(handleTrigger( get(triggerdata) ));"
      />
    </scene>

    Corresponding javascript function:

    However, it appears as though it still needs another parameter to parse the first one, which is weird. This works:
    XML markup:

    Code
    <scene name="scene_sceneOne" title="sceneOne" >
      <view />
      <preview />
      <image></image>
      <!-- place your scene hotspots here -->
      <hotspot name="spot1" ath="0" atv="0" triggerdata="{'type':'type1','id':'id'}"
      onclick="js(handleTrigger( get(triggerdata),get(somethingElse) ));"
      />
    </scene>

    Corresponding javascript function:

    I'm not quite sure why this works, but it does. Let me know if someone has any insight. Thanks!

  • You only need to pass the hotspot id. Then use get to find out the rest of the variables.
    krpano.get("hotspot["+hotspotid+"].name"); etc

    If you post an online working version, someone may have the time to mess around with troubleshooting.

    As a test, you may see if there's some javascript console that you can use the call the functions directly and if there's any difference.
    ie9 blarrgghhh

  • Thanks for the reply sachagrffin. Your workaround would probably in fact work, but I was hoping to be able to pass more than one parameter to the js() call. Your solution depends on more javascript (the parsing of the hotspot from javascript through the panoViewerObject.get() and would only work if all needed parameters were on the referenced hotspot. Furthermore, and I haven't verified it through testing, but I'm pretty sure that it wouldn't even pass the hotspot's id as a single parameter as demonstrated in the first attempted workaround. It's a good idea though if you only need variables on one hotspot.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!