Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
7165 Visualizzazioni

I want to take current active model name from URL in though JS code.Is there any other way?

Avatar
Abbandona
Autore

@Nivas. Thanks it works now.

Risposta migliore

You can use 'window.location.href' to get the current browser url.See my below code and you can get the current model name by splitting the string in JS.

// http://localhost:1287/web?db=mar_12#id=3&action=211&model=account.invoice&view_type=form&menu_id=88
var current_url = window.location.href;
var myArray = current_url.split("&");
var current_model = myArray[2].replace('model=',''); // model=account.invoice

Hope it will be useful for you.

Avatar
Abbandona
Risposta migliore

You can get current url using location.href and can get the current model using state data 
this.state.model  --- view renderer provide the model data and its context in state parameter.
So instead of splitting the URL to get the model name you can take the benefit of widget data.

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
dic 20
3878
1
lug 25
2163
2
lug 25
7671
2
lug 25
4094
2
lug 25
3836