Wednesday, April 11, 2012

jqm change select menu to basic list?

This might be really simple but I'm not used to this way of coding - How can I change this select menu:


$control .= '<select name="'. $this->_hash_value($hash, $xml_obj->value) .'" id="'. $this->_hash_value($hash, $xml_obj->value) .'" data-native-menu="false">';
 foreach ($nameArr as $folder => $imageArr) {
             foreach ($imageArr as $image) {
                 if (substr($folder, 1, strlen($folder)).$image == $xml_obj->value) {
                     $control .= '<option value="'. substr($folder, 1, strlen($folder)).$image .'" selected="selected">'. $image .'</option>';
                 } else {
                     $control .= '<option value="'. substr($folder, 1, strlen($folder)).$image .'">'. $image .'</option>';
                 }
             }
         }
         $control .= '</select>';
 


into a single list item (with the value of the currently chosen item) that leads to a basic list with all the items the user can choose from?



Answer:

You should be able to do something like this:
$control .= '<ul id="'. $this->_hash_value($hash, $xml_obj->value) .'" data-role="listview" data-theme="g">';
foreach($nameArr as $folder => $imageArr)
{
   foreach ($imageArr as $image) {
      $control .= '<li><a href="'. substr($folder, 1, strlen($folder)).$image .'">'. $image .'</a></li>';
   }
}
$control .= "</ul>";

No comments:

Post a Comment