File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change 5
5
v-model =" item.content"
6
6
:label =" config.translation.productId"
7
7
type =" textarea"
8
- @input =" updateTitle "
8
+ @input =" debouncedUpdateTitle "
9
9
/>
10
10
</div >
11
11
</template >
26
26
}
27
27
},
28
28
template: template,
29
+ data () {
30
+ return {
31
+ updateTitleTimeout: null
32
+ };
33
+ },
29
34
methods: {
35
+ debouncedUpdateTitle (value ) {
36
+ clearTimeout (this .updateTitleTimeout );
37
+ this .updateTitleTimeout = setTimeout (() => {
38
+ this .updateTitle (value);
39
+ }, 300 );
40
+ },
30
41
updateTitle (value ) {
31
42
let adminPath = window .location .pathname .split (' /snowmenu' )[0 ];
32
43
fetch (` ${ adminPath} /snowmenu/node/productName?isAjax=true&product_id=${ value} &form_key=${ window .FORM_KEY } ` , {
36
47
},
37
48
})
38
49
.then ((response ) => {
39
- console .log (response)
40
- // return response.json();
50
+ if (! response .ok ) {
51
+ throw new Error (response .status );
52
+ }
53
+ return response .json ();
54
+ })
55
+ .then (data => {
56
+ data .product_name && this .$set (this .item , ' title' , data .product_name );
41
57
})
42
- // .then(data => {
43
- // this.$set(this.item, 'title', data.name);
44
- // })
45
58
.catch (error => {
46
59
console .error (' Error fetching product name:' , error);
47
- // this.$set(this.item, 'title', value);
48
60
});
49
61
}
50
62
}
You can’t perform that action at this time.
0 commit comments