Answer the question
In order to leave comments, you need to log in
How to disable href navigation in a tag?
There is a link, it has ui-sref and ng-click. How to make it so that, depending on the condition that is in the called function on ng-click, the transition to the link in the ui-sref would either work or not?
Answer the question
In order to leave comments, you need to log in
$('a').click(function(){
if (true) { code } else{ return false; };
return false;
});
$( function(){
$('body').on('click','a[ui-sref]',function(e){ /* прехватываем событие и делигируем его для всех (существующих и/или еще не созданых a[ui-sref])*/
if (this['ng-click']) { /* проверяем ваше условие */
/* сделайте все чо вам нужно */
e.preventDefault(); /* Здесь запретим обрабатывать события броузеру */
} else return; /* иначе ссылка сработает */
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question