Added keepQuery option to router navigate.
This commit is contained in:
parent
0cdf431aa0
commit
41815a680d
@ -86,14 +86,16 @@ IgniteTemplate.prototype.route = function(routes, showCallback = null, hideCallb
|
|||||||
* @param {String|IgniteProperty|Function} route The route to navigate to.
|
* @param {String|IgniteProperty|Function} route The route to navigate to.
|
||||||
* @param {Any|IgniteProperty|Function} data The data to pass along with this navigate, this only applies when not refreshing, default is null.
|
* @param {Any|IgniteProperty|Function} data The data to pass along with this navigate, this only applies when not refreshing, default is null.
|
||||||
* @param {Boolean|IgniteProperty|Function} refresh Whether or not to refresh the page, default is false.
|
* @param {Boolean|IgniteProperty|Function} refresh Whether or not to refresh the page, default is false.
|
||||||
|
* @param {Boolean|IgniteProperty|Function} keepQuery Whether or not to keep the current url query, default is false.
|
||||||
* @returns {IgniteTemplate} This ignite template.
|
* @returns {IgniteTemplate} This ignite template.
|
||||||
*/
|
*/
|
||||||
IgniteTemplate.prototype.navigate = function(route, data = null, refresh = false) {
|
IgniteTemplate.prototype.navigate = function(route, data = null, refresh = false, keepQuery = false) {
|
||||||
return this.onClick(() => {
|
return this.onClick(() => {
|
||||||
Router.navigate(
|
Router.navigate(
|
||||||
(route instanceof IgniteProperty ? route.value : (route instanceof Function ? route() : route)),
|
(route instanceof IgniteProperty ? route.value : (route instanceof Function ? route() : route)),
|
||||||
(data instanceof IgniteProperty ? data.value : (data instanceof Function ? data() : data)),
|
(data instanceof IgniteProperty ? data.value : (data instanceof Function ? data() : data)),
|
||||||
(refresh instanceof IgniteProperty ? refresh.value : (refresh instanceof Function ? refresh() : refresh))
|
(refresh instanceof IgniteProperty ? refresh.value : (refresh instanceof Function ? refresh() : refresh)),
|
||||||
|
(keepQuery instanceof IgniteProperty ? keepQuery.value : (keepQuery instanceof Function ? keepQuery() : keepQuery))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -274,8 +276,18 @@ class Router {
|
|||||||
* @param {String} route The route to navigate to.
|
* @param {String} route The route to navigate to.
|
||||||
* @param {Any} data The data to pass along with this navigate, this only applies when not refreshing, default is null.
|
* @param {Any} data The data to pass along with this navigate, this only applies when not refreshing, default is null.
|
||||||
* @param {Boolean} refresh Whether or not to refresh the page, default is false.
|
* @param {Boolean} refresh Whether or not to refresh the page, default is false.
|
||||||
|
* @param {Boolean} keepQuery Whether or not to keep the current url query, default is false.
|
||||||
*/
|
*/
|
||||||
static navigate(route, data = null, refresh = false) {
|
static navigate(route, data = null, refresh = false, keepQuery = false) {
|
||||||
|
//If keepQuery is true then include the current query.
|
||||||
|
if (keepQuery) {
|
||||||
|
if (route.includes("?")) {
|
||||||
|
route = route.split("?")[0] + window.location.search;
|
||||||
|
} else {
|
||||||
|
route = route + window.location.search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
if (Router.hashMode) {
|
if (Router.hashMode) {
|
||||||
//In hash mode the route can't start with / or #, we have to handle it here.
|
//In hash mode the route can't start with / or #, we have to handle it here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user