Skip to content

Commit

Permalink
Adds option to reload items after they have already been loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
SQiShER committed Jun 10, 2016
1 parent 0b575b9 commit 869c2d9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
30 changes: 22 additions & 8 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,48 @@ System.config({

map: {
"array.prototype.findindex": "npm:array.prototype.findindex@1.0.0",
"babel": "npm:babel-core@5.8.34",
"babel-runtime": "npm:babel-runtime@5.8.34",
"babel": "npm:babel-core@5.8.38",
"babel-runtime": "npm:babel-runtime@5.8.38",
"core-js": "npm:core-js@1.2.6",
"jquery": "src/adapter/jquery-adapter.js",
"lodash": "npm:lodash@3.10.1",
"github:jspm/nodelibs-assert@0.1.0": {
"assert": "npm:assert@1.3.0"
"assert": "npm:assert@1.4.1"
},
"github:jspm/nodelibs-buffer@0.1.0": {
"buffer": "npm:buffer@3.6.0"
},
"github:jspm/nodelibs-path@0.1.0": {
"path-browserify": "npm:path-browserify@0.0.0"
},
"github:jspm/nodelibs-process@0.1.2": {
"process": "npm:process@0.11.2"
"process": "npm:process@0.11.3"
},
"github:jspm/nodelibs-util@0.1.0": {
"util": "npm:util@0.10.3"
},
"npm:assert@1.3.0": {
"npm:assert@1.4.1": {
"assert": "github:jspm/nodelibs-assert@0.1.0",
"buffer": "github:jspm/nodelibs-buffer@0.1.0",
"process": "github:jspm/nodelibs-process@0.1.2",
"util": "npm:util@0.10.3"
},
"npm:babel-runtime@5.8.34": {
"npm:babel-runtime@5.8.38": {
"process": "github:jspm/nodelibs-process@0.1.2"
},
"npm:buffer@3.6.0": {
"base64-js": "npm:base64-js@0.0.8",
"child_process": "github:jspm/nodelibs-child_process@0.1.0",
"fs": "github:jspm/nodelibs-fs@0.1.2",
"ieee754": "npm:ieee754@1.1.6",
"isarray": "npm:isarray@1.0.0",
"process": "github:jspm/nodelibs-process@0.1.2"
},
"npm:core-js@1.2.6": {
"fs": "github:jspm/nodelibs-fs@0.1.2",
"path": "github:jspm/nodelibs-path@0.1.0",
"process": "github:jspm/nodelibs-process@0.1.2",
"systemjs-json": "github:systemjs/plugin-json@0.1.0"
"systemjs-json": "github:systemjs/plugin-json@0.1.2"
},
"npm:inherits@2.0.1": {
"util": "github:jspm/nodelibs-util@0.1.0"
Expand All @@ -52,7 +66,7 @@ System.config({
"npm:path-browserify@0.0.0": {
"process": "github:jspm/nodelibs-process@0.1.2"
},
"npm:process@0.11.2": {
"npm:process@0.11.3": {
"assert": "github:jspm/nodelibs-assert@0.1.0"
},
"npm:util@0.10.3": {
Expand Down
4 changes: 2 additions & 2 deletions dist/virtual-select-jquery.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/virtual-select-jquery.min.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/core/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ function finishLoading(state, options) {
});
}

function resetLoadedItems(state) {
return $.extend({}, state, {
itemsLoading: false,
itemsLoaded: false,
});
}

const actions = {
startSelection,
cancelSelection,
Expand All @@ -120,6 +127,7 @@ const actions = {
toggleExtendedMode,
startLoading,
finishLoading,
resetLoadedItems,
};

export default actions;
10 changes: 10 additions & 0 deletions src/virtual-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ function VirtualSelect(element, userOptions) {
});
}

function reloadItems() {
changeState(fn.resetLoadedItems(state));
return loadItems();
}

function changeState(targetState) {
// FIXME: rendering the search input causes a blur event, which in return
// triggers another rendering cycle. in order for that to work, the state
Expand Down Expand Up @@ -137,6 +142,11 @@ function VirtualSelect(element, userOptions) {
loadItems();
};

this.reload = function reload() {
console.debug('item reload triggered');
reloadItems();
};

changeState(state);
}

Expand Down

0 comments on commit 869c2d9

Please sign in to comment.