script.aculo.us and MS Ajax RC1

0 views
Skip to first unread message

CtrlAltDel

unread,
Jan 21, 2007, 5:30:15 PM1/21/07
to Ruby on Rails: Spinoffs
What is the current state of play concerning integration between MS
Ajax and script.aculo.us? I've found that the Ajax Control Toolkit that
goes with it is pretty weak in comparison with Scriptaculous, but
putting Scriptaculous code into a page that is running within an
UpdatePanel stops the various effects from working.

Is it going to be the case that I need to break out a Javascript
debugger and find out where the incompatability is, or are there any
known issues?

P.S. This is using MS Ajax RC1 and Scriptaculous 1.7.

Malard

unread,
Jan 22, 2007, 4:11:11 AM1/22/07
to Ruby on Rails: Spinoffs
What is the error you are getting. Also the MS Ajax "Atlas" library is
probably incompatiable with the prototype.js library. Your mixing
frameworks!

CtrlAltDel

unread,
Jan 23, 2007, 8:11:29 PM1/23/07
to Ruby on Rails: Spinoffs
The later releases of MS Ajax are actually compatible with Prototype
(for instance, the $() function has been renamed to $get() so that
users can have both libraries running together).

I tracked down the problem to the fact that Javascript rendered inline
within an UpdatePanel is not executed, so where I was creating my
Sortable, that code wasn't being executed. After a lot of faffing
around, I moved the code outside of the UpdatePanel, and added an event
handler for the endRequest event, which is triggered after an MS Ajax
call has finished, something like this:

<script type="text/javascript">
// <![CDATA[
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandle);

function endRequestHandle(sender, args)
{
if (args.get_error() == null)
{
if ($("photoframe"))
{
Sortable.create("photoframe",
{
tag:'div',only:'photoimage',overlap:'horizontal',constraint:false,
onUpdate:function()
{
$("<%= SortOrderHiddenFieldID %>").value =
Sortable.serialize("photoframe");
}
});
}
}
}
// ]]>
</script>

(usually you handle this event so you can do some pretty error
handling, but it also works for me when using Scriptaculous). So when
the UpdatePanel had finished doing its Ajaxy trickery, I could then
bind the Scriptaculous Sortable to the "photoframe" div element if it
existed. From then on, it was all plain sailing (apart from having to
get a reference to the hidden field that I dumped the contents of
Sortable.serialize() into).

I've been *really* impressed by how easily Scriptaculous worked once
I'd got around this MS Ajax stumbling block. My colleagues are also
well impressed by how nice the Sortable stuff looks and works. I'd been
playing with the MS Ajax Control Toolkit and its ReorderList, and it
just wouldn't work. Scriptaculous? A handful of lines of Javascript,
and gorgeous drag-n'droppery of photos. So major kudos to the
Scriptaculous team for putting together something so useful!

Reply all
Reply to author
Forward
0 new messages