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">×</button>
<strong>Error!</strong> Username and/or password incorrect!
</div>
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With