Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
7170 มุมมอง

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.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ธ.ค. 20
3880
1
ก.ค. 25
2170
2
ก.ค. 25
7676
2
ก.ค. 25
4099
2
ก.ค. 25
3842