I have an AngularJs directive like this:
app.directive("showSuccess", function () {
return {
restrict: "A",
link: function (_scope, _element) {
_scope.$watch("successMessage", function (newVal) {
if (newVal) {
$(_element).find("#successMessage").html(newVal);
$(_element).slideDown().delay(3000).slideUp();
}
});
// Below code does not work
$(_element).find(".hide-message").on("click", function () {
$(_element).slideUp();
_scope.successMessage = "";
});
}
};
});
The related HTML is:
<div class="ui-state-success" show-success>
<i class="icon-ok-sign small"></i>
<span id="successMessage"></span>
<i class="icon-remove hide-message"></i>
</div>
When the panel is triggered to slide down, the screen shot is:

The problem is, when I click the "×", the panel won't slide up (although that it will slide up anyway after 3s delay).
I know I can do this using ng-click. But anyone knows why it does not work in this case? Thanks.
ng-clickto your element instead of using jquery$(_element).find(".hide-message")resolving? Can you console.log() the element you're trying to select and verify it is the right dom element? Even just a console.log() in the click function to see if it is even being called