Created
April 16, 2017 17:04
-
-
Save richjenks/b471aba4f809680223a64967bf4e28e3 to your computer and use it in GitHub Desktop.
Ratchet Vue.js modal switch
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
// v-on:click handlers can only take one expression, so you can't close | |
// a modal and update vars in one. This function updates vars on the | |
// current Vue object, closes a modal (based on CSS selector) and, | |
// optionally, opens another modal after a delay to all appear smooth | |
modalNav: function(vars, close, open) { | |
for (var attr in vars) { this[attr] = vars[attr]; } | |
document.querySelectorAll(close)[0].classList.remove('active') | |
if (typeof open !== 'undefined') { | |
window.setTimeout(function () { | |
document.querySelectorAll(open)[0].classList.add('active') | |
}, 250); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Only works with top-level values in
data
and cannot set, for example, array items.