I am using jQuery AJAX to send data to the controller. That data is then used to grad a record for editing from the DB. If the request it load the data from the db into a modal window for editing. The data is written to the page in a foreach loop like this:
<?php if(sizeof($menu)) : ?>
<?php foreach($menu as $item): ?>
<div class="menu_item grid_7">
<div class="menu_item_top grid_7">
<h3><?php echo $item->name; ?></h3>
</div><!-- menu_item_top -->
<p class="menu_item_text">
<?php echo $item->description; ?>
</p>
<p class="price"><?php echo '$'.$item->price; ?></p>
<?php if(isset($this->session->userdata['is_admin'])):?>
<div class="menu_item_admin grid_6">
<a class="edit_link" href="/admin/edit/wsrmenuitems/<?php echo $item->id;?>">Edit</a>
<a class="admin_Link" href="/admin/delete/<?php echo $item->id;?>">Delete</a>
<a class="logout" href="/login/logout/">Log Out</a>
</div><!-- end menu_item_admin -->
<?php endif;?>
</div><!-- end menu_item -->
<?php endforeach;?>
<?php else : ?>
<h2>No results to display</h2>
<?php endif; ?>
So naturally everything is the same. This works fine on one page, but when on another page that loads up a different menu the jQuery only works on the first item in the foreach loop. Here is the jQuery:
$('.edit-form-portlet').hide();
$('.edit_link').live("click",function(eve){
eve.preventDefault();
data = $(this).attr('href');
$.get(data, function(data) {
$('.edit-form-portlet').html(data);
$('.edit-form-portlet').dialog({
height:600,
width: 600,
modal: true
});
});
});
The only difference between the two menu pages is the 3rd segment of the edit_link URI. One goes to wsrmenuitems and everything works on that page. The other goes to sushi and this is where it only works on the very first item in the foreach loop. The ajax request runs but I don't get anything back from the db. So I get a bunch of trying to get a property of non-object errors.