[英]I would like to have my edit function to work when i click on the edit image
I would like to have my edit function to work when i click on the edit image. 当我单击编辑图像时,我希望我的编辑功能能够正常工作。 I have a function to edit an event but it wont work when i click on the image. 我具有编辑事件的功能,但是单击图像后它将无法正常工作。 The delete code works when i click on the event: delete function/edit function: 当我单击以下事件时,删除代码有效:删除功能/编辑功能:
eventMouseover: function(event, domEvent) {
var layer = '<div id="events-layer" class="fc-transparent" style="position:absolute; width:100%; height:100%; top:-1px; text-align:right; z-index:100"><a><img src="../../images/editbt.png" title="edit" width="14" id="edbut'+event.id+'" border="0" style="padding-right:3px; padding-top:2px;" /></a><a><img src="../../images/delete.png" title="delete" width="14" id="delbut'+event.id+'" border="0" style="padding-right:5px; padding-top:2px;" /></a></div>';
$(this).append(layer);
$("#delbut"+event.id).hide();
$("#delbut"+event.id).fadeIn(300);
$("#delbut"+event.id).click(function() {
$.ajax({
url: '<?=base_url();?>testcalendar/fullcalendar/delete_events.php',
data: 'id=' + event.id ,
type: "POST",
});
var nTime = 1 * 50;
window.setTimeout("location.reload()", nTime);
});
$("#edbut"+event.id).hide();
$("#edbut"+event.id).fadeIn(300);
$("#edbut"+event.id).click(function() {
var title = prompt('Current Event Title: ' + event.title + '\n\nNew Event Title: ');
if(title){
$.ajax({
url: '<?=base_url();?>testcalendar/fullcalendar/update_title.php',
data: 'title='+ event.title+'&id='+ event.id ,
type: "POST",
});
}
});
},
delete_events.php: delete_events.php:
<?php
$id = $_POST['id'];
try {
$bdd = new PDO('mysql:host=localhost;dbname=develop-calendar', 'root', 'root');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
$sql = "DELETE from evenement WHERE id=".$id;
$q = $bdd->prepare($sql);
$q->execute(array($id));
?>
update_title.php: update_title.php:
<?php
$id = $_POST['id'];
$title = $_POST['title'];
// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=blackboks-calendar', 'calendar-boks', '19xantia');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// update the records
$sql = "UPDATE evenement SET title=".$title "WHERE id=".$id;
$q = $bdd->prepare($sql);
$q->execute();
?>
When i click on the edit icon there is an prompt to edit the title but when i type in a new title and click on ok it wont update. 当我单击编辑图标时,会提示您编辑标题,但是当我键入新标题并单击确定时,它将不会更新。 i think that there is something wrong with my update_title.php file but i dont know for sure. 我认为我的update_title.php文件出了点问题,但我不确定。
There is a problem here 这里有问题
$sql = "UPDATE evenement SET title=".$title "WHERE id=".$id;
Needs to be 需要是
$sql = "UPDATE evenement SET title=" . mysql_real_escape_string($title) . " WHERE id=" . mysql_real_escape_string($id);
Indeed, the space before WHERE I edited already on previous answer. 确实,在我之前编辑的WHERE之前的空格中。
You can also always try to debug what is returning by the script if you look into the Network tab inside Developer Console (F12 in most browsers). 如果您查看开发者控制台(在大多数浏览器中为F12)内的“网络”标签,也可以始终尝试调试脚本返回的内容。
Or check the results of the ajax call. 或者检查ajax调用的结果。
$.ajax({
url: '<?=base_url();?>testcalendar/fullcalendar/delete_events.php',
data: 'id=' + event.id ,
type: "POST",
}).done(function(data) {
alert(data); // Only for testing
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.