Maybe I'm approaching this wrong? Here is simplified version of what
I'm trying to do.

<!DOCTYPE html PUBLIC "-//W4C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" dir="ltr"
lang="en">
<head>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/
jquery.min.js" type="text/javascript"></script>
  <script type="text/javaScript" src="./apeDir/APE_JSF/Clients/
JavaScript.js"></script>
  <script type="text/javaScript" src="./apeDir/APE_JSF/Demos/
config.js"></script>
  <script>
        var client;
        $(document).ready(function(){
           client = new APE.Client();
           client.load({'channel': '*tapdicom'});
           client.addEvent('load', function() {
               client.core.start({'name': new
Date().getTime().toString()});
           });

           client.addEvent('multiPipeCreate', function(pipe) {
              client.onRaw('info', function(params) {
                 console.log('testReturn: '+params.data.testReturn);
               });
           });

           $('#testButton').on('click', function(){
              console.log('clicky');
              client.addEvent('multiPipeCreate', function(pipe) {
                 pipe.request.send('getInfo', {'testData': 'ABC'});
              });
          });
        });
</script>
</head>
<body>
<div id='testButton'>click</div>
</body>
</html>

Click the button, console displays message but no event is fired
according to network. It's driving me insane! I had a bit of a hard
time getting the SQL up and running (spider monkey error), finally got
that sorted and converted everything over from my original ajax code
and it was working great from my testing page but as soon as I try to
trigger a send from elsewhere in the code it fails. :(


On May 11, 11:22 am, Maxus <[email protected]> wrote:
> Actually cant be a channel issue as the server side module prints to
> the ape log as soon as 'getinfo' is called. :/
>
> On May 11, 10:20 am, Maxus <[email protected]> wrote:
>
>
>
>
>
>
>
> > Thanks for the reply, tried both with no success. I know it's not
> > scope completely because if I declare 'client' globally (placing 'var
> > client;' at the top of doc) it knows about it. ie changing
> > 'client.addEvent()' to 'client.add1Event'  produces Uncaught
> > TypeError: Object [object Object] has no method 'add1Event'. But
> > doesn't seem to fire when its right.
> > Its like the object is there but they aren't on the same channel?
>
> > On May 11, 12:28 am, Omar Chanouha <[email protected]> wrote:
>
> > > Try removing the var from the client declaration. Or declare client
> > > outside of the document.ready
>
> > > -O
>
> > > On Thu, May 10, 2012 at 8:49 AM, Maxus <[email protected]> wrote:
> > > > Can someone please help, I'm sure there is something simple I'm
> > > > missing but I just can't get it.
>
> > > > I'm including Clients/JavaScript.js, Demos/config.js and my custom js
> > > > script file in the parent document. Within the js script file I'm
> > > > trying to use APE but am having issues.
>
> > > > Within a jquery document ready function I'm loading the server etc.
> > > > ie:
>
> > > > var client = new APE.Client();
>
> > > > client.load({'channel': 'test'});
> > > > client.addEvent('load', function() {
> > > >   client.core.start({'name': new Date().getTime().toString())});
> > > > });
> > > > client.addEvent('multiPipeCreate', function(pipe) {
> > > >   client.onRaw('info', function(params) {
> > > >      console.log('info: '+params.data.item1+' - '+params.data.item2+'
> > > > - '+params.data.item3);
> > > >   });
> > > > });
>
> > > > This works fine. I then have a bunch of functions which I'd like to
> > > > add send events to. So I try adding this code to them:
>
> > > > client.addEvent('multiPipeCreate', function(pipe) {
> > > >   pipe.request.send('getInfo', {'input1': 'abc', 'input2': 'xyz',
> > > > 'input3': '123'});
> > > > });
>
> > > > Its strange as it only ever works if it's placed straight below the
> > > > top code that creates the client and connects to the server... Even if
> > > > its placed directly within an onclick listener, within the document
> > > > ready block it fails to fire. I'm sure it's scope related but can't
> > > > work it out. Please help as I'm losing the little hair I have left! :)
>
> > > > Thanks
> > > > Maxus
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "APE Project" group.
> > > > To post to this group, send email to [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/ape-project?hl=en
> > > > ---
> > > > APE Project (Ajax Push Engine)
> > > > Official website :http://www.ape-project.org/
> > > > Git Hub :http://github.com/APE-Project/

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to