Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 基于实体的结束日期在中显示/隐藏数据_Javascript_Symfony_Twig - Fatal编程技术网

Javascript 基于实体的结束日期在中显示/隐藏数据

Javascript 基于实体的结束日期在中显示/隐藏数据,javascript,symfony,twig,Javascript,Symfony,Twig,houdini在我的html中是一个tr。tr处于循环中。它在我的约会实体中循环,并为每个约会打印一个tr。 现在我想隐藏一个约会,如果它过期了,它将被删除,然后淡出,滚动到未来的其他约会。 但是由于类名的原因,它根本不显示tr 有人能解决这个问题吗 顺便说一句,我正在使用Symfony与细枝模板 这是HTML window.setInterval(function() { var expiryDate = $('.houdini').attr('data-enddat

houdini在我的html中是一个tr。tr处于循环中。它在我的约会实体中循环,并为每个约会打印一个tr。 现在我想隐藏一个约会,如果它过期了,它将被删除,然后淡出,滚动到未来的其他约会。 但是由于类名的原因,它根本不显示tr

有人能解决这个问题吗

顺便说一句,我正在使用Symfony与细枝模板

这是HTML

window.setInterval(function()
    {

        var expiryDate = $('.houdini').attr('data-enddate');

        var current = new Date();
        var expiry = new expiryDate;

        if (current.getTime() > expiry.getTime())
        {
            $('.houdini').hide();
        }

        else if (current.getTime() < expiry.getTime())
        {
            $('.houdini').show();
        }

    });

这篇文章可能会对你有用,如果你有任何错误,请告诉我

 <tbody>
        {% for appointment in appointments %}
            <tr class="houdini" data-endDate="{{appointment.endDate|date('Y-m-d H:i')}}">
                <td>{{appointment.startDate|date('H:i')}}</td>
                <td>{{appointment.client.companyname}}</td>
                <td>{% for employee in appointment.employees %}
                        {{employee.firstname}}{% if not loop.last %}, {% endif %}
                    {% endfor %}</td>
                <td>{{appointment.description}}</td><br>
            </tr>
        {% endfor %}
        </tbody>


我认为数据的结果不是一个日期,而是一个字符串。您可以将Date.getTime保存在数据中,并将其转换为intager,而不是保存日期。

也发送html。。。。
window.setInterval(function()
{
    var houdiniElements = $('.houdini');
    for(var i =0; i < houdiniElements.length; i++) {
        var expiryDate = $(houdiniElements[i]).data('enddate'); // Here probably if you are using some different date format than you need to parse it accordingly...

        var current = new Date();
        var expiry = new Date(expiryDate);

        if (current.getTime() > expiry.getTime()){
            $(houdiniElements[i]).hide();
        } else if (current.getTime() < expiry.getTime()){
            $(houdiniElements[i]).show();
        }
    }
},1000); //1000 miliseconds = 1second
var correctStart = '2012-11-10T13:10:13';
var date = new Date(correctStart);
var start = '10/11/2012 13:10:13';    
var date = new Date(start);