I'm using chosen for a dynamic multiselect, see link.
I works perfectly but when I put it in a view which a call with ajax the javascript doesn't work anymore.
So how can I run a javascript after a ajax request.
the view with the request:
<div id="searchField">
<?php
echo $this->Form->create('SearchForQuestions');
?>
<fieldset>
<legend><?php __('Zoeken'); ?></legend>
<?php echo $this->Form->input('mainTopic',array('label' => 'Vak:','empty' => true)); ?>
<div id="loader" style="display:none"><?php echo $this->Html->image('loader.gif'); ?></div>
<div id="childTopics"></div>
</fieldset>
<?php
echo $ajax->observeField('SearchForQuestionsMainTopic',
array(
'url' => array( 'action' => 'get_children' ),
'frequency' => 0.2,
'indicator' => 'loader',
'update' => 'childTopics'
)
);
echo $this->Form->end();
?>
the view which is called with ajax:
<?php echo $this->Html->css(array('chosen'),'stylesheet', array('inline' => false ) ); ?>
<h1>Chosen</h1>
<div class="side-by-side clearfix">
<div>
<em>Multiple Select with Groups</em>
<select data-placeholder="Your Favorite Football Team" style="width:350px;" class="chzn-select" multiple tabindex="6">
<option value=""></option>
<option>Dallas Cowboys</option>
<option>New York Giants</option>
<option>Philadelphia Eagles</option>
<option>Washington Redskins</option>
<optgroup label="NFC NORTH">
<option>Chicago Bears</option>
<option>Detroit Lions</option>
<option>Green Bay Packers</option>
<option>Minnesota Vikings</option>
</optgroup>
</select>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js" type="text/javascript"></script>
<script src="/experimenten/js/chosen.proto.js" type="text/javascript"></script>
<script type="text/javascript">
document.observe('dom:loaded', function(evt) {
var select, selects, _i, _len, _results;
if (Prototype.Browser.IE && (Prototype.BrowserFeatures['Version'] === 6 || Prototype.BrowserFeatures['Version'] === 7)) {
return;
}
selects = $$(".chzn-select");
_results = [];
for (_i = 0, _len = selects.length; _i < _len; _i++) {
select = selects[_i];
_results.push(new Chosen(select));
}
deselects = $$(".chzn-select-deselect");
for (_i = 0, _len = deselects.length; _i < _len; _i++) {
select = deselects[_i];
_results.push(new Chosen(select,{allow_single_deselect:true}));
}
return _results;
});
</script>
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment