0

Using this wiki I have a dynamic dropdownlist working just fine. Instead of the related data populating another dropdownlist I just want all the related values to display at once on the screen in some sort of formatted list.

I changed the update in the ajax action to 'update'=>'#cities', and added to my view...

<div id="cities"> 
   <?php echo $model->relatedCities; ?>
</div 

and to my model

public function getRelatedCities()
{
   $out=CHtml::listData($this->cities,'CityId','Name');
   return implode('<br />', $out);
}

When I make my selection in my dropdownlist nothing is updated in <div id="cities"> and the ajax call in firebug looks fine.

So how can I display the dynamic related content from the dropdownlist all at once?

4
  • Might be wrong, but shouldn't $model->relatedCities be $model->RelatedCities? Commented Feb 24, 2012 at 0:11
  • No that is not a factor here. Commented Feb 24, 2012 at 0:16
  • 1
    Have you confirmed that $out is actually returning something? Commented Feb 24, 2012 at 0:38
  • try my solution below, it should work. Commented Feb 24, 2012 at 6:51

1 Answer 1

2

This is a problem with your action, you have to echo instead of return.

Because your ajax call is expecting html data, and not some string.
So try this:

public function getRelatedCities()
{
 $out=CHtml::listData($this->cities,'CityId','Name');
 echo implode('<br />', $out);
}

p.s: Assuming that you have verified that $out is not empty.

Sign up to request clarification or add additional context in comments.

1 Comment

ask for clarifications if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.