[Rails-spinoffs] Re: Autocompleter inside a page load in Ajax

2006-12-28 Thread asteriskmail


UpDate in Firefox in Macbook does not work, firefox on windows is
working and in IE7 does not work

Any idea

On Dec 28, 9:19 am, [EMAIL PROTECTED] wrote:

Hi,
if I update my page and try to use autocompleter does not work.
The same page loaded directly work.
I believe that there is a problem to get the right id.
Any idea or examples how to solve this.

Thank you



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Spinoffs group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~--~~~~--~~--~--~---



[Rails-spinoffs] Re: Autocompleter inside a page load in Ajax

2006-12-28 Thread Christophe Porteneuve


[EMAIL PROTECTED] a écrit :


Hi,
if I update my page and try to use autocompleter does not work.
The same page loaded directly work.
I believe that there is a problem to get the right id.
Any idea or examples how to solve this.


I suppose you mean you have some AJAX-based behavior that replaces a
part of your page where you use Auto-completion?

Basically, any dynamic replacement of DOM fragments that are used by
such features as Draggable/Sortable/Autocompleter/etc. means extra care
is necessary.  Essentially, you would need to use the following sequence:

1. deregister any such behavior (Droppables.remove, Sortable.destroy, etc.)
2. actually replace the DOM fragment
3. Re-create/register the behavior (Droppables.add, Sortable.create, new
Ajax.Autocompleter, etc.).

This is because the features resolve IDs to actual DOM references, and
then keep using those references.  To nodes that get removed from the
DOM by later replacement...  So you need to use freshly-obtained
references, even if those use the same IDs.

'HTH

--
Christophe Porteneuve a.k.a. TDD
[They] did not know it was impossible, so they did it. --Mark Twain
Email: [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Spinoffs group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~--~~~~--~~--~--~---



[Rails-spinoffs] Re: Autocompleter inside a page load in Ajax

2006-12-28 Thread Christophe Porteneuve


Il Neofita a écrit :

If do you have time can you explain to me a little bit more, since I do
not know nothing regarding Draggable and Sortable, I will appreciate
your help.


Actually, in your specific case (which, I gather, only involved
auto-completion), there are only two event handlers being created when
you do:

new Ajax.Autocompleter(...);

- one on blur
- one on keypress

They both tackle your input field.

When you replace the DOM fragment that contains your input field (do you
really need to?!), those events never get fired again, because what the
user types in is another field, a new one, created by your
fragment-replacing code (e.g. the processing of a Ajax.Updater, or a
call of yours to Element.replace or Element.update).

It's not too bad that you didn't remove those two event observers;
they're not going to be triggered, and the garbage collector will handle
them properly.

However, what you need, at the minimum, is to follow DOM replacement by
an identical call to new Ajax.Autocompleter(...), to recreate the
functionality for your new DOM elements.

Still, the question remains:  why on Earth do you replace your
auto-completed field (and its completion zone)?  Can't you do otherwise?

--
Christophe Porteneuve a.k.a. TDD
[They] did not know it was impossible, so they did it. --Mark Twain
Email: [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Spinoffs group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~--~~~~--~~--~--~---



[Rails-spinoffs] Re: Autocompleter inside a page load in Ajax

2006-12-28 Thread Il Neofita

I will try to explain what I am doing.

I have a page loaded with a table, when I press in a row the table is
reloaded and in the row that I selected I put the input box. If I do this
the autocompleter does not work. Now, I cannot understand how I can solve
this problem having the new event hadler to point to this new element.

Thank you

On 12/28/06, Christophe Porteneuve [EMAIL PROTECTED] wrote:



Il Neofita a écrit :
 If do you have time can you explain to me a little bit more, since I do
 not know nothing regarding Draggable and Sortable, I will appreciate
 your help.

Actually, in your specific case (which, I gather, only involved
auto-completion), there are only two event handlers being created when
you do:

new Ajax.Autocompleter(...);

- one on blur
- one on keypress

They both tackle your input field.

When you replace the DOM fragment that contains your input field (do you
really need to?!), those events never get fired again, because what the
user types in is another field, a new one, created by your
fragment-replacing code (e.g. the processing of a Ajax.Updater, or a
call of yours to Element.replace or Element.update).

It's not too bad that you didn't remove those two event observers;
they're not going to be triggered, and the garbage collector will handle
them properly.

However, what you need, at the minimum, is to follow DOM replacement by
an identical call to new Ajax.Autocompleter(...), to recreate the
functionality for your new DOM elements.

Still, the question remains:  why on Earth do you replace your
auto-completed field (and its completion zone)?  Can't you do otherwise?

--
Christophe Porteneuve a.k.a. TDD
[They] did not know it was impossible, so they did it. --Mark Twain
Email: [EMAIL PROTECTED]





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Spinoffs group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~--~~~~--~~--~--~---



[Rails-spinoffs] Re: Autocompleter inside a page load in Ajax

2006-12-28 Thread Marius Feraru


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Il Neofita wrote:

test.html
[...]
td onclick=new Ajax.Request('/test1.html', {asynchronous:true,
onSuccess: function(t) {
$('replace').innerHTML=t.responseText;}})R21/td

^ You are not evaluating response scripts, but merely replacing the
content of replace. Call t.responseText.evalScripts() to fix it.

A less ugly way would be to use Ajax.Updater instead:

td onclick=new Ajax.Updater('replace', '/test1.html',
{evalScripts:true})R21/td

(OFC, even less ugly would be to move away all those inline scripts, but
that's already a different story).

cheers
- --
Marius Feraru
-BEGIN PGP SIGNATURE-

iD8DBQFFlI8ttZHp/AYZiNkRAv2rAKCQwj8+i6ETuWzDY6MQqBWYwSH99ACg55HG
A7b9PISx9tuduOdTqxE8je0=
=Cgci
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Spinoffs group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~--~~~~--~~--~--~---