javascript - Jquery 1.9 - declare variable after load -
<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 <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 $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 read</a> <?php else: ?> <a role=unread href="<?php echo base_url('admin/contact_messages_read/' . $msg['id_contact']) ?>">mark 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 sure want delete 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>
after load, variables set not usable (or don't exists). how can redeclare variables (html part variables inside container)?
for basic_info
reference elements of basic_info
class, assignment has made after domready. if number of basic_info
elements may change, assignment has made @ point in time want information valid.