Hi,
I have a problem with Ajax when I try to load new content. When I load
new content into div using ajax and then I try to click on an ajax
link placed into the same div I get an error "Event.observe is not a
function". I see that this is a common problem but still I was not
able to find how to fix it.
Here is the link that loads into the div:
$ajax->link($html->image($img, array('alt' => 'Delete', 'border' =>
'0')), "/uploads/delete/$id_property/$id_img", array('update' =>
'allimages', 'class' => 'koko'), "Are you sure you wish to delete this
image?", false);
and here is sample code for my controller:
class UploadsController extends AppController {
var $name = 'Uploads';
var $components = array('Image', 'RequestHandler');
var $layout = 'ajax';
function add($id = null) {
$offer_id = $id;
$result = $this->Image->upload_image_and_thumbnail($this-
>data,"name1",573,80,"uploaded",true);
if($result == 'empty') {
__('empty');
} else {
$savedata = Array('Upload' => Array('id' => null,
'estate_id' =>
$offer_id, 'img' => $result));
if($this->Upload->save($savedata, false)) {
$this->set('all_images',
$this->selectall($offer_id));
$this->set('id_property', $offer_id);
}
}
}
function delete($id_property = null, $id_img = null) {
$this->Upload->del($id_img);
$this->set('all_images', $this->selectall($id_property));
$this->set('id_property', $id_property);
}
function selectall($id = null) {
return $this->Upload->findAll("Upload.estate_id = $id");
}
}
and here is sample view for the delete and add action:
if(isset($all_images)) {
foreach($all_images as $img) {
$id_img = $img['Upload']['id'];
$img = "uploaded/small/".$img['Upload']['img'];
echo $ajax->link($html->image($img, array('alt' =>
'Delete',
'border' => '0')), "/uploads/delete/$id_property/$id_img",
array('update' => 'allimages', 'class' => 'koko'), "Are you sure you
wish to delete this image?", false);
}
}
Basically I'm uploading a picture which then refreshes a div with the
same picture and a link to delete it. But when I upload the picture
and try to click on delete it gives me this error: "Event.observe is
not a function". The strange thing is that it works fine if I simply
try to delete an image that is uploaded already. But if I try to
upload which is essentially the same code it gives me an error. As far
as I understand this has something to do with including prototype but
it's included and working fine with the delete action of my
controller. The problem comes after I use the add action.
I will be thankful if anyone suggests a solution! Thank you in
advance!
regards,
Kik
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---