[Proto-Scripty] Re: Namespace Function

2009-04-21 Thread RobG

On Apr 22, 9:57 am, disccomp  wrote:
> Here's the working code:http://pastie.org/454045

OK, here it is:

| $N = function(ns){

*Always* declare variables.  I can't see why you don't use:

  function $N(ns) {

or, because I dislike the use of $ in variable names:

  function getNamespace(ns) {
...
  }

|   /* First split the namespace string separating each level of the
namespace object.*/
|   var splitNs = ns.split(".");

Ensure you have a string before trying to call one of its methods,
otherwise you'll get an error:

  var splitNs = String(ns).split('.');


|   /* Define a string, which will hold the name of the object we are
currently working with. Initialize to the first part.*/
|   var builtNs = splitNs[0];

builtNS might be undefined, a moot point since it isn't used.


|   var i, base = window;

Do not augment host objects, use the global object.  You can get a
reference to the global object using:

  var base = (function(){ return this;})();


|   for (i = 0; i < splitNs.length; i++){
| if (typeof(base[ splitNs[i] ]) == "undefined") base[ splitNs
[i] ] = {};
| base = base[ splitNs[i] ];
|   }

A couple of points:

 1. Store a refernce to splitNs[i] so you don't have to keep getting
it.

 2. typeof is not a function so the brackets around the argument
aren't required:

var nsPart;
for (var i=0, len=splitNs.length; ihttp://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Namespace Function

2009-04-21 Thread disccomp

Oops, left hand assignment error, didn't quite work the way I thought
it would.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Namespace Function

2009-04-21 Thread disccomp

Here's the working code: http://pastie.org/454045
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Namespace Function

2009-04-21 Thread disccomp

Came across this page: 
http://blog.arc90.com/2008/06/an_easy_way_to_implement.php

This function would make a nice utility function to include in
Prototype, call it $N.

So, $N('first.second.third.request) = New Ajax.Request(...

$N Would make sure that each level of the namespace exists then return
the full object which can then be chained further.

-Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] onEnterEditMode destination is undefined

2009-04-21 Thread Newb.aculo.us

When I add onEnterEditMode to Ajax.InPlaceEditor, it seems to function
as I would expect, but in the Firefox version 3.0.8 Error Console on
Mac Leopard, I get "destination is undefined" for Line 108 in
prototype.js version 1.6.0.3 bundled with script.aculo.us version
1.8.2.
"destination[property] = source[property];"

1) Should I be returning something in onEnterEditMode to satiate
Prototype?

Based on code from
http://wiki.github.com/madrobby/scriptaculous/ajax-inplaceeditor
How to execute custom code using the InPlaceEditor’s callbacks.
I do the following:
new Ajax.InPlaceEditor(id, url, {
onEnterEditMode: function(form, value) {
// custom code goes here...
alert('onEnterEditMode: form[' + form + '] value[' + 
value + ']');
}}
);

I get an alert like so:
onEnterEditMode: form[[object Object]] value[undefined]

Notice that the variable "value" is undefined.
2) Is the signature correct?

Note also that the earlier example on that page with:
callback: function(form, value) { return 'myparam=' +
encodeURIComponent(value) }
sends my server side script the posted variable "myparam", so I don't
see why "value" is undefined for onEnterEditMode.

FYI fellow noobs, a little gem I found is that "editorId" is passed in
the ajax request and holds the id of the editor.  Had this been
documented on this page I would not have spent the last 2 days
learning more than I ever wanted to know about the innards of
Prototype & script.aculo.us.

Also, using an id in the body tag did not work in IE, but works in FF
and Safari.  But you probably wouldn't use it there and I was just
testing it there when I started with the InPlaceEditor.

"(Should these callback options be documented in the Options list
above?)"
Yes, please document these options.

More clarification on ajaxOptions would have helped me, but I was able
to do what I wanted in onComplete.

Regards.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Help with binding

2009-04-21 Thread ColinFine



On Apr 12, 2:20 am, kstubs  wrote:
> So quickly I go from "I got it", to scratching my head and "I don't
> got it" but, I have made your changes and it works!  I guess then
> I only need to _bind_ in the case where I define my function for my
> timer and in my Event _observe_ definitions?.  Sound about right?
>
You need to use 'bind' when
 - you want to use 'this' in your function, and
 - it is not going to get set automatically, eg. by calling the
function as a method.

That's all.

Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: AJAX calls from multiple browser tabs at the same time:

2009-04-21 Thread Walter Lee Davis

I'm not sure what the issue might be under Struts, but in PHP, you  
have to make sure that your sessions are closed immediately when  
trying to run multiple requests like this. I ran into something that  
sounds exactly as you describe a year and change ago, and making sure  
that the session in the parent page was closed before letting an Ajax  
request fly made all the difference. If you have two pages open in  
separate tabs, and those pages each grab a session and your server  
doesn't terminate and write those sessions to disk, you may have a  
lock there against using those sessions again in your Ajax call.

Walter

On Apr 21, 2009, at 6:17 AM, NN wrote:

>
> When an user tries to send AJAX requests simultaneously from multiple
> browser tabs, one request gets completed and the page loads but the
> other AJAX calls are preempted. As a result of which the response is
> empty for the other calls. Only one call survives. In my application
> using struts 2.0, JSP and javascript and the prototype framework, i
> found that the server response is empty in the cases mentioned above
> though the data gets updated in teh database with the request
> parameters. The onSucess event handler for Ajax.request gets called
> but the the response is empty.
>
> Can you please help?
>
> Thanks
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: AJAX calls from multiple browser tabs at the same time:

2009-04-21 Thread Richard Quadling

2009/4/21 NN :
>
> When an user tries to send AJAX requests simultaneously from multiple
> browser tabs, one request gets completed and the page loads but the
> other AJAX calls are preempted. As a result of which the response is
> empty for the other calls. Only one call survives. In my application
> using struts 2.0, JSP and javascript and the prototype framework, i
> found that the server response is empty in the cases mentioned above
> though the data gets updated in teh database with the request
> parameters. The onSucess event handler for Ajax.request gets called
> but the the response is empty.
>
> Can you please help?
>
> Thanks
>
> >
>

Under normal circumstances, you can only have 2 active connections per
server. You have to work within that limitation.

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: AJAX calls from multiple browser tabs at the same time:

2009-04-21 Thread T.J. Crowder

Hi,

Are you sure this isn't caused at the server side?  For instance, can
you replicate the behavior if the calls just request static files?  It
would be extremely surprising if Ajax calls in different windows
(browser tabs are different windows) interacted with each other at
all, other than the common two-concurrent-requests-to-the-same-
endpoint limit (but if you run into that -- and you probably do --
they'll just queue, not come back empty).  My money is on the server
stuff (JSPs, struts, whatever) being the culprit and not handling
overlappings requests in the same session correctly.

FWIW,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Apr 21, 11:17 am, NN  wrote:
> When an user tries to send AJAX requests simultaneously from multiple
> browser tabs, one request gets completed and the page loads but the
> other AJAX calls are preempted. As a result of which the response is
> empty for the other calls. Only one call survives. In my application
> using struts 2.0, JSP and javascript and the prototype framework, i
> found that the server response is empty in the cases mentioned above
> though the data gets updated in teh database with the request
> parameters. The onSucess event handler for Ajax.request gets called
> but the the response is empty.
>
> Can you please help?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] the effect in Effect.toggle does not work

2009-04-21 Thread Ram

Hi all,

I have an RoR app in which Im using Effect.toggle('id', 'slide') to
show and hide a div.

However, the actual effect of sliding does not show (neither do
'blind' or 'appear'). Instead, there is a delay (of approximately the
time that the effect might take) and the div is just displayed
abruptly. The same happens when I toggle it again to hide it too.

The effects were working a few months back. I have changed a lot in
the meanwhile in the app as a whole but I dont see why that should
cause this problem to arise. The code im using is this..

erb template
<%= link_to_function image_tag("/images/comments_y2.jpg"),
"toggle_comments();" %>

application.js
function toggle_comments() {
new Effect.toggle('comms', 'slide');
return false;
}

comms div



...


<% form_remote_for ... %>
  ...
<% end %>

<%= link_to_function "Close", "toggle_comments();"%>




Could anyone tell me where im breaking the effect?
Thank you

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] AJAX calls from multiple browser tabs at the same time:

2009-04-21 Thread NN

When an user tries to send AJAX requests simultaneously from multiple
browser tabs, one request gets completed and the page loads but the
other AJAX calls are preempted. As a result of which the response is
empty for the other calls. Only one call survives. In my application
using struts 2.0, JSP and javascript and the prototype framework, i
found that the server response is empty in the cases mentioned above
though the data gets updated in teh database with the request
parameters. The onSucess event handler for Ajax.request gets called
but the the response is empty.

Can you please help?

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Problem with update

2009-04-21 Thread T.J. Crowder

@Mona:

Good catch!

@nroose:

Expanding slightly on what Mona was saying, TR is not longer a valid
child element of TABLE in modern doc types, you must have a TBODY (or
a THEAD or TFOOT) in between.  Most browsers will helpfully insert one
for you if you leave it out of your markup, but that causes problems
when you're doing dynamic DOM manipulation.  This particular problem
-- the way it keeps getting moved down a pixel -- is fascinating. :-)
And easily replicated.

So the moral is:  Put in a TBODY and put the rows in that:






...and you should be okay.  (In the above I moved the id to the TBODY,
which means your code could be left unchanged.)

The W3C validator[1] may be helpful when diagnosing problems like this
in the future, it would have flagged up the missing tbody assuming you
have a proper doc type on your doc (which you should if you're using
Prototype).

[1] http://validator.w3.org/

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Apr 21, 8:22 am, Mona Remlawi  wrote:
> 2 things, i advice you to add the global css rule
> table {border-collapse: collapse}
> and to insert your rows into table/tbody element
> 
> this would make it work for FF and IE
>
> on the other hand, if you are building dom elements on the fly, why
> not take a look at following links
>
> http://wiki.github.com/madrobby/scriptaculous/builderhttp://www.prototypejs.org/api/template
>
> very handy and will save you tons of code.
>
> cheers
>
> --
> mona
> mreml...@optaros.com
>
> --
>
> On Mon, Apr 20, 2009 at 8:44 PM, nroose  wrote:
>
> > I have code that removes the content of a table and then redraws it.
> > It works great in Safari, but in firefox, the content that I draw in
> > moves down a couple of pixels each time I draw it.
>
> > I have reproduced it with only a little bit of code:
>
> > 
> >  > script>
> > 
> > 
> > 
> >