Dyego Oviedo
Dyego Oviedo

Reputation: 308

onclick and ng-click event not working

I am working with Onsen UI (angularjs) + Cordova and I have this problem: I have a button that is not working right now, but this button was working sometime ago. Now I cannot even get click event of the button. Does somebody know what is the problem?

HTML:

<ons-list id="list-actions" style="border-top: none"><ons-list-item style="line-height: 1; padding: 0;">
        <ons-row class="action">
          <ons-col class="bt-pres action-col col {{interaction[0].present}}">
            <div class="action-icon"><ons-icon icon="ion-fireball"></ons-icon></div>
            <div class="action-label">Press</div>
          </ons-col>

Javascript:

  //not working
  $(document).on("click",".bt-pres",function(){
    alert("clicked");

Upvotes: 1

Views: 3343

Answers (2)

Dyego Oviedo
Dyego Oviedo

Reputation: 308

Thanks for all your replies. Looking the code again and over again, my bad was I had twice codes like $(document).on('click', elem, func) and it was in conflict. Then I changed this to use angular ngclick function inside controller. This worked like a charm. Thank you all

Upvotes: 1

Charitha
Charitha

Reputation: 127

First of all alert() is not working in neither ripple nor device (as per my knowledge). If you want to trigger the function i suggest ng-click()

example HTML

<div ng-controller="LoginController">
   <ons-button ng-click="Login()">Login</ons-button>
</div>

JS

.controller('LoginController', function () {
   $scope.Login = function () {
      console.log("triggered");
   }
}

in your case try the bellow code

$(document).on("click","div.action-label",function(){
    console.log("triggered");
}

Upvotes: 0

Related Questions