Ajax.Updater - update vs replace

33 перегляди
Перейти до першого непрочитаного повідомлення

Andrew Kaspick

не прочитано,
25 січ. 2008 р., 20:57:5925.01.08
Кому: prototy...@googlegroups.com
Hi,

Not sure if this has come up before, but I was thinking that an option
for Ajax.Updater to allow for a 'replace' call instead of the current
'update' would be useful.

I find that I don't always want to update a given section of html, but
would rather replace it entirely.

Thoughts?

As an aside for rails usage, remote methods could get an additional
:replace option to go along with the :update one if this functionality
was included in prototype.

Andrew

kangax

не прочитано,
26 січ. 2008 р., 02:36:1326.01.08
Кому: Prototype: Core
Simple subclassing should do the job (haven't tested but it should
work):

Ajax.Replacer = Class.create(Ajax.Updater, {
initialize: function($super, container, url, options) {
options = options || { };
options.onComplete = (options.onComplete ||
Prototype.emptyFunction)
.wrap(function(proceed, transport, json) {
$(container).replace(transport.responseText);
proceed(transport, json);
})
$super(container, url, options);
}
})

new Ajax.Replacer("someElement", "someUrl");

Andrew Kaspick

не прочитано,
27 січ. 2008 р., 04:33:4627.01.08
Кому: prototy...@googlegroups.com
So is this something worthy of core prototype?
Відповісти всім
Відповісти автору
Переслати
0 нових повідомлень