views:

29

answers:

1

Hello...I am attempting to create a dynamic favorites list in this application i'm working on. My problem at the moment is I cannot direct an event to toggle specific li class names. I have a large list of li's and seperate pages associated with them. Each page has a title bar with several image links, phone number, etc. the last image is a star which i need to have turn blue when the user clicks on it as well as toggle the class of its corresponding li element on another page. I don't want to have to write individual code for each element and i am becoming more frustrated trying to correlate each star click with one of 37 li elements... i have used jquery but cannot figure this out...

div containing li elements i need to toggle in order to clone them to another "favorites" list

<div id="barlist">
  <div class="toolbar"><h1>Bar List</h1><a class="button back"Back</a>
     <a class="button flip" Settings</a>
 </div>
 <ul class="edgetoedge">    
   <li class="aleHouse"><a Ale House</a></li>
   <li class="argyle"><a Argyle</a></li>
   <li class="bearlys"><a Bearlys</a></li>
   <li class="bostonPizza"><a>Boston Pizza</a></li>
 </ul>
</div>

corresponding page with star image

<div id="aleHouse">
   <div class="toolbar"><h1>Ale House</h1><a class="button back" >Back</a>    
</div>
<div>
<div class="blackBar">
  <img class="white" img src=".../whitestar40(png)" alt="star">
</div>

$("document").ready(function() {
  $("#barlist li[class=fav]").clone().appendTo("#favorites[class=edgetoedge]");
});

$("document").ready(function() {  
  $(".white").click(function() {   $(???this???).toggleClass(".fav");  })
});

for instance, when the whitestar40 is clicked, i want it to turn blue and also clone the the ale house li (which was clicked to get to this page) and appendTo my favorites list on another page

A: 

I'm assuming that you are displaying both these pages at the same time? ...As opposed to trying to store the info(that the whitestar40 was clicked) across the request. I'd start by adding some attribute to the whitestar40 that keeps track of what li was clicked, and set it when that click happens. Then you have the data you need in the html/dom on the other page. Does that help or get the juices flowing?

Noremac
thank you for the input :)