Created
July 24, 2017 08:56
-
-
Save andrea-ale-sbarra/9f11297d675d8bfe9ab52deb31f199bd to your computer and use it in GitHub Desktop.
manage field via vue and checkbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style="clear: both;"></div><br/> | |
<div class="control-group" id="enabledNotificationGroup"> | |
<label class="control-label" for="enabledNotification">Enable Email Notification:</label> | |
<div class="controls"> | |
<input type="checkbox" class="form-control input-xxlarge" th:field="*{enabledNotification}" id="enabledNotification" v-model="isEnabled" v-on:click="eraseValue" /> | |
<span class="help-inline"> | |
<span th:each="err : ${#fields.errors('enabledNotification')}" th:text="${err}"></span> | |
</span> | |
</div> | |
</div> | |
<div style="clear: both;"></div><br/> | |
<div class="control-group" id="notificationEmailGroup"> | |
<label class="control-label" for="notificationEmail">Notification Email:</label> | |
<div class="controls"> | |
<input type="text" class="form-control input-xxlarge" th:field="*{notificationEmail}" id="notificationEmail" :disabled="!isEnabled" v-model="inputValue" /> | |
<span class="help-inline"> | |
<span th:each="err : ${#fields.errors('notificationEmail')}" th:text="${err}"></span> | |
</span> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vue = new Vue({ | |
el : '#acerUserForm', | |
data : { | |
isEnabled : /*[[${userModel.enabledNotification}]]*/true, | |
inputValue : /*[[${userModel.notificationEmail}]]*/'' | |
}, | |
methods : { | |
eraseValue : function() { | |
if (!this.isEnabled) { | |
this.inputValue = ''; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment