|
|
|
@ -25,6 +25,9 @@ import '../app' |
|
|
|
|
* |
|
|
|
|
* the data-async-load is the attribute responsible for binding the store. |
|
|
|
|
* |
|
|
|
|
* data-no-first-loading attribute can also be used along with data-async-load |
|
|
|
|
* to prevent loading items for the first time |
|
|
|
|
* |
|
|
|
|
* If the page has a redux associated with, you need to connect the reducers instead of creating |
|
|
|
|
* the store using the `createStore`. For instance: |
|
|
|
|
* |
|
|
|
@ -39,6 +42,8 @@ import '../app' |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
var enableFirstLoading = true |
|
|
|
|
|
|
|
|
|
export const asyncInitialState = { |
|
|
|
|
/* it will consider any query param in the current URI as paging */ |
|
|
|
|
beyondPageOne: (URI(window.location).query() !== ''), |
|
|
|
@ -310,7 +315,10 @@ function firstPageLoad (store) { |
|
|
|
|
function loadItemsPrev () { |
|
|
|
|
loadPage(store, store.getState().prevPagePath) |
|
|
|
|
} |
|
|
|
|
loadItemsNext() |
|
|
|
|
|
|
|
|
|
if (enableFirstLoading) { |
|
|
|
|
loadItemsNext() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$element.on('click', '[data-error-message]', (event) => { |
|
|
|
|
event.preventDefault() |
|
|
|
@ -334,7 +342,12 @@ function firstPageLoad (store) { |
|
|
|
|
|
|
|
|
|
const $element = $('[data-async-load]') |
|
|
|
|
if ($element.length) { |
|
|
|
|
const store = createStore(asyncReducer) |
|
|
|
|
connectElements({ store, elements }) |
|
|
|
|
firstPageLoad(store) |
|
|
|
|
if (Object.prototype.hasOwnProperty.call($element.data(), 'noFirstLoading')) { |
|
|
|
|
enableFirstLoading = false |
|
|
|
|
} |
|
|
|
|
if (enableFirstLoading) { |
|
|
|
|
const store = createStore(asyncReducer) |
|
|
|
|
connectElements({ store, elements }) |
|
|
|
|
firstPageLoad(store) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|