Answer the question
In order to leave comments, you need to log in
How to call actions in a specific controller using Javascript in Yii2?
The problem is this: the site menu is drawn using SVG code due to the complexity of the presentation. How can I run actions? Let's say I want to run site/login from the demo. OUTSIDE an svg block, the following command works: <?= Html::a(Yii::t('app', '0'), ['site/login']) ?>
But inside an svg block, it doesn't work:
<svg>
...
<text id="s3" transform="matrix(1 0 0 1 80.3013 72.0967)" fill="#D4EBFF" font-family="'ArialMT'"
font-size="29" style="cursor: pointer;"><?= Html::a(Yii::t('app', '0'), ['site/login']) ?>
</text>
...
</svg>
$('#s3').click(function(){
$.post('/yii2/controllers/SiteController.php', {r:'site/login'});
});
$('#s3').click(function(){
$.post('?r=site/login');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question