Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper way to get ui element with jquery inside a ItemView Marionette.js

I'm learning Marionette.js and would like know the correct way to get the ui element to manipulate it with jQuery. In my LoginItemView I'm declaring the ui elements and an function to display a error message of invalid login:


ui: {
  username: "#username",
  password: "#password",
  btnLogin: "#btnDoLogin",
  messageContainer: "#messageContainer"
},
displayMessage: function() {
  // show error message
  $(this.ui.messageContainer.selector).show();
},

I also tried:


  $(this.ui.messageContainer[0]).show();

but the message is never displayed.
And here is the code of containerMessage in the template.

<div class="alert alert-danger alert-dismissable login-message-display" id="#messageContainer" style="display: none;">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
    <strong>Error!</strong> Username and/or password incorrect!
</div>
like image 930
rodrigopandini Avatar asked Mar 21 '23 10:03

rodrigopandini


1 Answers

There is no need to add selector on the ui element. ui is a simple object to map the selectors to keys.

Just use

$(this.ui.messageContainer).show();
like image 148
Billy Chan Avatar answered Apr 06 '23 13:04

Billy Chan