Sie sind nicht angemeldet.

1

Mittwoch, 24. April 2013, 10:10

js()-functions in jQuery

Hello,
I tried to get the current scene-title and want to show() and hide() div´s with the ID of the scene-title.

eg. having following html:

Quellcode

1
2
<div id="scene1"></div>
<div id="scene2"></div>


And when scene1 will be loaded the div#scene1 should be shown.

I tried to test:

XML:

Quellcode

1
2
3
<action name="startactions">
       js( showtitle(get(scene[get(xml.scene)].title)) );
</action>


jQuery

Quellcode

1
2
3
4
5
$(document).ready(function() {
     function showtitle(scenetitle) {
          alert(scenetitle);
     }
};


But the alert doesnt work ant krpano says:

Zitat

WARNING: js() - calling Javascript "showtitle(get(scene[get(xml.scene)].title))" failed: Error: ReferenceError: showtitle is not defined


What´s the problem here? Because for me it looks that showtitle() is defined, but I am a JS-Newbie :)

Best regards,
Marc

2

Mittwoch, 24. April 2013, 11:32

Hi!
It's true
showtitle - is not defined in main scope

It's possible in this case

<script>
$(document).ready(function() { showtitle('Some title'); };

function showtitle(scenetitle) {
alert(scenetitle);
}
</script>

Hope it help
Regards
Andrey
VRAP - desktop VR content player based on krpano.
Common tasks in one place in one click! Discussion thread
DOWNLOAD for MAC
DOWNLOAD for WIN

3

Mittwoch, 24. April 2013, 11:48

Hi,
I can get the alert if I just write this:

Quellcode

1
2
3
4
5
<script>
function showtitle(scenetitle) {
alert(scenetitle);
}
</script>


But I want to use the "scenetitle"-variable in jQuery like

$('#scenetitle').show();

but "scenetitle" should be the title of the current scene of course.

Marc