小编git*_*ter的帖子

如何在activeForm中为字段添加id前缀?

我有两个表单拥有相同的模型属性,因为 Yii2 生成的字段 id 为ModelName-fieldName所以生成的字段如下:

<select name="Channel[channel]" class="form-control" id="channel-description">
Run Code Online (Sandbox Code Playgroud)

我曾尝试使用fieldConfig的ActiveForm,但它不ID添加到域本身。

yii2 active-form

6
推荐指数
1
解决办法
4103
查看次数

为什么这段代码无法执行'fetch'?

我正在使用服务工作者进行推送通知.我正在使用XHR(Ajax)方法来获取我的通知,这是service-worker.js的代码片段:

 var API_ENDPOINT = new Request('/getNotification', {
redirect: 'follow'});

event.waitUntil(
    fetch(API_ENDPOINT, {credentials: 'include' })
        .then(function(response) {

            console.log(response);
            if (response.status && response.status != 200) {
                // Throw an error so the promise is rejected and catch() is executed
                throw new Error('Invalid status code from API: ' +
                    response.status);
            }
            // Examine the text in the response
            return response.json();
        })
        .then(function(data) {
            console.log('API data: ', data);

            var title = 'TEST';
            var message = data['notifications'][0].text;
            var icon = data['notifications'][0].img;

            // Add this to …
Run Code Online (Sandbox Code Playgroud)

service-worker push-api

2
推荐指数
1
解决办法
4771
查看次数

标签 统计

active-form ×1

push-api ×1

service-worker ×1

yii2 ×1