次の jquery コードは機能しますが、jquerymobile 選択フォームでは表示されません。プレーンな選択HTMLを表示します。ajax されたページ レンダー jquerymobile 選択フォームをバインドするにはどうすればよいですか。
前もって感謝します。
echo '<div data-role="fieldcontain" id="subject">'."\n";
echo '<label for="subjectid"><em>* </em> Subject: </label>'."\n";
if(!empty($subjectlist))
{
echo form_dropdown('subjectid', $subjectlist, NULL, 'id="subjectid" class="required" data-theme="c"')."<br />\n";
}
else
{
echo "No subject registered. Contact the application administrator.";
}
echo "</div>\n\n";
echo '<div data-role="fieldcontain" id="teachernamediv">'."\n";
echo "</div>\n\n";
....
....
<script>
$(document).ready(function() {
$('#loader').hide();
$('#teachernamediv').hide();
$('#subjectid').change(function(){
$('#loader').show();
var findteacher = "<?php echo base_url(); ?>index.php/welcome/user/findteacher";
$.post(findteacher, {
subjectid: $('#subjectid').val(),
teachergrp: "5",
user_id: $('input[name=id]').val(),
}, function(response){
setTimeout("finishAjax('teachername', '"+escape(response)+"')", 200);
});
return false;
});
});
function finishAjax(id, response){
$('#loader').hide();
$('#'+id+'div').html(unescape(response));
$('#'+id+'div').fadeIn();
}
<script>
そして、これはuser.phpです
function findteacher()
{
if($_POST['subjectid'])
{
//$grade = $_POST['grade'];
$subject_id = $_POST['subjectid'];
$teachergrp = $_POST['teachergrp'];
$user_id = $_POST['user_id'];
// check if student has a techerid in hw_user_subject with this subjectid
$findteacher = $this->Mhomework->findSubjectTeacher($user_id, $subject_id);
if(!empty($findteacher))
{
$data['teacher']=$findteacher;
$data['header']=$this->preference->item('site_name');
$this->load->view('common/teacher', $data);
}
else
{
// if there is no teacher then get a list of teacher names
$data['teachers'] = $this->Mhomework->findteacher($subject_id,$teachergrp);
$data['header']=$this->preference->item('site_name');
$this->load->view('common/teachers', $data);
}
}
else
{
redirect ('welcome','refresh');
}
}
これはteachers.phpです
echo '<label for="teachername"><em>* </em> Subject Teacher: </label>'."\n";
$option = array (
''=>'-- Select Teacher --'
);
foreach($teachers as $row)
{
$gender=get_gender($row['gender']);
$option [$row['user_id']]=$gender." " . $row['last_name'];
}
echo form_dropdown('teachername', $option, NULL, 'id="teachername" class="required" data-theme="c" ')."<br />\n";