I'm a beginner using the Yii web framwork , and I'd like know why this code is not working.
In main.php
<a href="#" onclick="modal()"> test modal</a>
In script.js
function modal(){
$.ajax({
url: 'index.php?r=Site/ModalRegister',
success: function(){
$('.large.modal').modal('show');
}
});
}
In siteController.php
public function actionModalRegister(){
$this->renderPartial('//site/ModalRegister');
}
In site/ModalRegister.php
<div class="ui large modal">ddd</div>
Well, you do this
function modal(){
$.ajax({
url: 'index.php?r=Site/ModalRegister',
success: function(){
$('.large.modal').modal('show');
}
});
}
On success you try to show the <div class="ui large modal">ddd</div>
that comes from the ajax itself. But before you show it you have to insert it someplace in the DOM of the page. You should change it to something like
function modal(){
$.ajax({
url: 'index.php?r=Site/ModalRegister',
success: function(html){
$( "body" ).append(html);
$('.large.modal').modal('show');
}
});
}