Tuesday, September 28, 2010

Re: JS helper

for the record:
Seems that above function despite having additional class is still
bound to the same event executing both open and close.

Since I could not find solution to this in reasonable time I've
implemented following workaround:

$(function()
{
$('div.Commands a.CmdOpen').click(function(ev)
{
ev.preventDefault();
var target = $(this).parent('div').next('div.Target');
if ($(this).is('.Active')) {
$(this).removeClass('Active');
target.slideUp().html('');
} else {
$(this).addClass('Active');
$("#busy-indicator").clone().appendTo(target).show();
$.ajax({
url: $(this).attr('href'),
cache: false,
success:
function(html)
{
target.slideDown().html(html);
},
error:
function (XMLHttpRequest, status, errorThrown)
{
alert('error ...');
}
});
}
});
});

At present I only experience one problem - indicator is visible only
on the first click, following clicks work but do not display busy
indicator while awaiting ajax response.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: