MyBB Community Forums

Full Version: Quickdelete
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I wanna use the quickdelete function for my blog system. I created therefore the file comment.js in the folder jscripts:
var Comment = {
	init: function()
	{
	},
	
	deleteComment: function(cid)
	{
		confirmReturn = confirm(quickdelete_confirm);
		if(confirmReturn == true) {
			form = document.createElement("form");
			form.setAttribute("method", "post");
			form.setAttribute("action", "editcomment.php?action=deletecomment&delete=yes");
			form.setAttribute("style", "display: none;");

			var input = document.createElement("input");
			input.setAttribute("name", "cid");
			input.setAttribute("type", "hidden");
			input.setAttribute("value", cid);

			form.appendChild(input);
			document.getElementsByTagName("body")[0].appendChild(form);
			form.submit();
		}
	},
}
Event.observe(window, 'load', Comment.init);

The template code is this one:
<script type="text/javascript">
document.write('<a href="javascript:Comment.deleteComment({$cid});"><img src="images/bluenight\/postbit_delete.gif" alt="Diesen Kommentar löschen" title="Diesen Kommentar löschen" \/><\/a>');
</script>

But when I click on the button nothing happens. What is going wrong?
Did you add the comments.js to your headerinclude template?
yeah, I did
Did you get any Javascript errors? Did the confirm prompt come up? Does editcomment.php have the right PHP code?
editcomment.php has the right code, the confirm prompt does not come up and there are no errors
I just look it up in the java console and got the error:
confirm(quickdelete_confirm); is not defined

How can I solve that problem?
In your blog template, you'll need to add in the appropriate location:
<script type="text/javascript">
		 var quickdelete_confirm = "{$lang->quickdelete_confirm}";
</script>

Make sure that the appropriate $lang is loaded as well!