跳至內容
選單
此問題已被標幟
2 回覆
7203 瀏覽次數

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

頭像
捨棄
作者

@Nivas. Thanks it works now.

最佳答案

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.

頭像
捨棄
最佳答案

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.

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
12月 20
3903
1
7月 25
2300
2
7月 25
7767
2
7月 25
4186
2
7月 25
3966