How to fire a function or process based on value on url

I want to open a window and the data on this window is loaded based on some key on the url, so it's like $_GET on PHP. how can i achieve this ?

here is the snippet https://snippet.webix.com/6tre8f9l

Tagged:

Comments

  • edited March 18
  • Is there anyway we can do this by webix ? and where we supposed to handle this, I mean in which method in a view ?

  • And when I tried the url something like http://localhost/ptct/webix-old/vcp_v1/#!/app/dashboard?id=7899, webix assumed that dashboard?id=7899 is the name of my view, webix can't separate them. any suggestions?

  • edited March 19

    I presume you are using Webix Jet with HashRouter.
    in this case dashboard is your view and id is parameter.
    you can access id using getParam method of view.
    if you are using old version of Jet, try to use : instead of ? as parameter separator.
    http://localhost/ptct/webix-old/vcp_v1/#!/app/dashboard:id=7899

  • Hey I really appreciate your help, but please one more thing. How can i use this getParam method ?

    I've tried several ways, and yes I'm using the old version of webix

    $oninit: function (view, scope) {

           // I have tried this way
            // require(["app"], function (app) {
            //     app.getParam('id');
            // });
    
            // And this way
            // this.getParam('id');
    
           // but still the mothod is undefined
        },
    
  • as far as I remember you can use $onurlchange method to process url or parameters changing.

    {
        $onurlchange(params, stack) {
            if (params.id) {
                ...
            }
        }
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!