Saturday, March 24, 2012

call global javascript function - help

hi forum,

i want to call a global javascript function from

<invokeMethodmethod="gobalFunction"/>

it's throw an error of no instance

i have readed the good page at

http://www.wilcob.com/Wilco/Atlas/DeclarativelyInvokingJavaScript.aspx

but this

<atlas:ButtonID="btnServer"runat="server"Text="call">

<behaviors>

<atlas:ClickBehavior>

<ClickHandler="globalFunction"/>

</atlas:ClickBehavior>

</behaviors>

</atlas:Button>

just doesn't compile, i guess because is december ctp. I'm using January ctp

i tried the client way i have seen at the same page

<click handler="globalFunction"/>

or

<ClickBehavior click="globalFunction"/>

there is no error but the function is not called.

So i want to try the last way

<ClickBehavior>
<Click>
<Actions>
<InvokeMethodAction Target="myWindow" Method="test" />
</Actions>
</Click>
</ClickBehavior>


but don't know how to set the id 'myWindow' to link the method call.

Finally, i'm here asking if someone can show me a way to call a global function from an atlas client component.

thanks

oops

just have to say thanks to the atlas team for their work. I can't understand yet all the power in this framework, but it looks great

hector

It's me again,

no replies, may be the question was not in the right way or it's so stupid that nobody want to reply it.

I just started with atlas and my programming level is low (being kind to me), but it's hard, there is not docs and when you find some pieces often is not working against the current release.

As a suggestion for the forum i would like at the top section a page with useful links about atlas ex.

http://www.nikhilk.net/

http://www.wilcob.com/Wilco/Atlas.aspx

http://weblogs.asp.net/bleroy

so people can add good links to a central location easy to find.

OK. this post it's to show a solution for the problem i posted before.

----

Type.registerNamespace("HostChan");

HostChan.HostSite =function() {

HostChan.HostSite.initializeBase(this, [true]);

var _hostApp = window.external;

this.getDescriptor =function() {

var td = HostChan.HostSite.callBaseMethod(this,'getDescriptor');

td.addProperty('hostApp', Object,true);

td.addMethod('sayHello');

return td;

}

this.initialize =function() {

HostChan.HostSite.callBaseMethod(this,'initialize');

eval('window.' +this.get_id() +' = this;');

}

this.get_hostApp =function() {

return _hostApp;

}

this.sayHello =function() {

alert("hello");

}

}

Type.registerClass('HostChan.HostSite', Web.Component);

Web.TypeDescriptor.addType('gdc','hostSite', HostChan.HostSite);

--

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005" xmlns:gdc="gdc">

<components>

<gdc:hostSite id="theHost" />

<button targetElement="btnJs">

<click>

<invokeMethod target="theHost" method="sayHello" />

</click>

</button>

</components>

</page>

</script>

-------

I created a custom component derived from

Web.Component

added properties and methods and override the

initialize

function where i it create a global object named instance with the id supplied in the xml script

I liked before to create javascript objects better than global functions but i still would like some one show me the way to call a global javascript function from the

invokeMethod

tag in the xml script

sorry for the long post

have a happy day

No comments:

Post a Comment