Skip to content

Commit

Permalink
Remove dependency from vue-multiselect. Make it optional and check if…
Browse files Browse the repository at this point in the history
… loaded. Add it to dev files.
  • Loading branch information
Lionel Bijaoui committed Aug 5, 2016
1 parent 24c49d9 commit 7e3472d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js"></script>
<script type="text/javascript" src="https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.min.js"></script>
</head>
<body>
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,5 @@
"dependencies": {
"babel-runtime": "6.9.2",
"vue": "1.0.24",
"vue-multiselect": "^1.0.1"
}
}
}
13 changes: 9 additions & 4 deletions src/fields/fieldVueMultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@
<script>
// import { isObject } from "lodash";
import abstractField from "./abstractField";
import Multiselect from "vue-multiselect";
export default {
mixins: [abstractField],
components: {
Multiselect
},
computed: {
options() {
let values = this.schema.values;
Expand Down Expand Up @@ -82,5 +78,14 @@ export default {
console.log("onClose", value, id);
}
}
created() {
// Check if the component is loaded
if (window.VueMultiselect) {
Vue.component("multiselect", window.VueMultiselect.default);
} else {
console.error("'vue-multiselect' is missing. Please download from https://github.com/monterail/vue-multiselect and load the script in the HTML head section!");
}
}
};
</script>

0 comments on commit 7e3472d

Please sign in to comment.