Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
7161 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả

@Nivas. Thanks it works now.

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 20
3874
1
thg 7 25
2136
2
thg 7 25
7638
2
thg 7 25
4076
2
thg 7 25
3821