[Proto-Scripty] Re: Ajax.Request

2009-12-21 Thread heeae
sorry for typing mistake, I am intended to represent the concept of
using callback.
and I think keeping default variable is not bad as we cant tell the
default value not to be changed in the next generation of prototype
js.

heeae

On Dec 22, 1:25 pm, joe t. thooke...@gmail.com wrote:
  function show(){alert(get_data_default());}

 This line will fail when you call show() because you're not passing a
 function to fill the callback variable inside get_data_default().

 Also, method:post and asynchronous:true are the defaults for those
 options. You don't need to specify them if you plan to keep those
 settings.
 -joe t.

 On Dec 20, 10:47 pm, heeae csche...@gmail.com wrote:

  I will using this approach

  function get_data_default(callback){
  new Ajax.Request('/adress',
    {
      method:'post',
      asynchronous:true,
      onSuccess: function(data){ callback(data.responseText.evalJSON
  (true); },
      onFailure: function(){ alert('Something went wrong...') }
    });

  }

  function show(){alert(get_data_default());}

  var data = null;
  function processData(obj){ data = obj; alert(data.abc); }
  if(data == null){
  get_data_default(processData);

  }else{
  alert(data.abc);
  }

  On Dec 20, 7:35 pm, kangur91 kangu...@gmail.com wrote:

   My code:

   function get_data_default() {
   new Ajax.Request('/adress',
     {
       method:'post',
       asynchronous:true,
       onSuccess: function(data){ return data.responseText.evalJSON
   (true); },
       onFailure: function(){ alert('Something went wrong...') }
     });}

               }
   function show(){alert(get_data_default());}

   I want to function get_data_default return data recived from OnSucces
   function. How do that?



--

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-scriptacul...@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: Prototype with Raphael

2009-12-20 Thread heeae
um... i have not used raphael.
you want to toggle Class name to $(container) ? or the sub element
created by raphael?
for first one, simply $(container).toggleClassName(...)
for the second one, you have to know how raphael works
but i think raphael will provide a way to the get html element from
c.node (e.g. c.node.elements[0])
toggleClassName can only work in htmlElement, try to find the exact
htmlelement first in order to use html related functions

heeae

On Dec 17, 8:07 pm, code1n lomov...@gmail.com wrote:
 hello everyone.
 i'm trying to use raphael svg graphic library with prototype
 there is a question wich is troubeling me - how to extend svg elements
 with prototype?
 For example, i use this code:

 r = Raphael($(container), 300, 300);
 c = r.circle(100, 100, 50);
 c.attr('fill', 'red');
 c.node.toggleClassName(half_opacity)

 this doesn't works because c.node.toggleClassName(half_opacity)
 enteres enteres to  toggleClassName(element, className) function with
 first argument half_opacity and undefied second element. it has same
 effect as i've been calling Element.toggleClassName(asd).
 c.node.toString() returns [object SVGCircleElement]. SVGCircleElement
 inherits SVGElement, wich has Element as Superinterface.
 I tried Object.extend(c.node, Element), but it doesn't make sence.

 I liked to use Raphael in my work, using it with Prototype will brings
 more facilities.
 One more question - is there any svg library wich supports prototype?

--

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-scriptacul...@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.