<div class="main_content grid_9 clearfix omega">
<div class="basic_info">
<p>You have
<?php
$msg = count($messages);
$msg_tekst = ($msg == 1) ? 'message.' : 'messages.';
echo $msg . ' ' . $msg_tekst;
?>
</p>
<p>Show all
<a role=show_msg href="<?php echo base_url('admin/contact_messages/unread') ?>">unread </a>
|
<a role=show_msg href="<?php echo base_url('admin/contact_messages/read') ?>">read </a>
messages.
</p>
</div>
<!-- START CONTACT MESSAGES -->
<div class="contact_messages">
<?php foreach ($messages as $msg) : ?>
<article class="box contact_message clearfix">
<h2><?php echo $msg['name'] ?></h2>
<p><?php echo $msg['comment'] ?></p>
<a role=delete href="<?php echo base_url('admin/contact_messages_delete/' . $msg['id_contact']) ?>">Delete Message</a>
<?php if($msg['read'] == 0) : ?>
<a role=read href="<?php echo base_url('admin/contact_messages_read/' . $msg['id_contact'] . '/read') ?>">Mark as read</a>
<?php else: ?>
<a role=unread href="<?php echo base_url('admin/contact_messages_read/' . $msg['id_contact']) ?>">Mark as unread</a>
<?php endif ?>
</article>
<?php endforeach; ?>
</div>
<!-- END CONTACT MESSAGES -->
</div>
<!-- END MAIN_CONTENT -->
<script>
$(document).ready(function() {
var basic_info = $('.basic_info'),
show_msg = basic_info.find('a[role=show_msg]'),
contact_messages = $('.contact_messages'),
read = contact_messages.find('a[role=read], a[role=unread]'),
title = 'Contact Message Delete',
message = 'Are you sure you want to delete this message?';
delete_admin(title, message);
function msg_load(container, url)
{
container.slideUp('fast', function(){
container.empty().load(url, function(){
container.slideDown('fast');
});
});
};
// AJAX MESSAGES SHOWING
show_msg.on('click', function(e){
var $this = $(this),
url = $this.attr('href'),
url_info = url + ' .basic_info > *',
url_msg = url + ' .contact_messages > *';
msg_load(basic_info, url_info);
msg_load(contact_messages, url_msg);
return false;
});
});
</script>
加载后,设置的变量不可用(或它们不存在)。如何重新声明这个变量(变量的 HTML 部分在容器内)?