Reputation: 2396
I want to pop-up a jQuery Ui Dialog, but it doesnt work. Instead of dialog, i get a new page opened. My code is next:
Controller's action:
public function diaAction()
{
$viewModel = new ViewModel();
$viewModel->setTerminal(true);
return new ViewModel();
}
index.phtml:
<a class="some-link" title="title here" href="<?= $this->url('dialog', array('action' => 'dia'))?>">open form</a>
dia.phtml (dialog code)
<script type="text/javascript">
$(document).ready(function() {
$('.some-link').each(function() {
var $link = $(this);
var $dialog = $('<div></div>')
.load($link.attr('href'))
.dialog({
autoOpen: false,
title: $link.attr('title'),
});
});
});
</script>
I just don't get it, why this is not as simple as it should be. Any help?
Upvotes: 0
Views: 822
Reputation: 1058
In my opinion, the javascript is just not at its right place. It is called by the index.phtml, not the dia.phtml. How can it be executed it the browser just doesn't know the existence of it? I think my answer comes too late for you but I hope it will help some other people.
Upvotes: 0
Reputation: 1395
You have to handle 'click' so it show the dialog instead of following a link. Something like this:
$('.table a.button').on('click',function(e){
e.preventDefault();
$('<div></div>')
.load($link.attr('href'))
.dialog({
autoOpen: false,
title: $link.attr('title'),
});
});
Upvotes: 1