خرید بک لینک

Vote count: 0

I am leaing Meteor and I am trying to check a box for a task and have in tu JQuery strike out the text when it is checked. I have helpers in place that show me data the way I want it to and also event handler so that when the inout is checked it updates the db.

What I want is to be able to test if the db says 'completed' and if so strike out the a tag text. I have written a helper to do that but am unsure of where in the template to put the helper. I also would like to know if at the time of checking the box and the db being updated does the template re- render when there is a change in the db.

Here is my code:

<template name="item">
<div class="left" style="border-bottom:1px solid lightslategray;border-radius:.2em;">
    <div class="left"><!--left-->
        <li>
            <input class="items js-checked" id="checked" type="checkbox">
        </li>
        <li>
            <a href="#" class=" items js-update-task-form js-complete">
                {{task}}
            </a>
        </li>

        <div class="clear"></div>
    </div>
    <div class=" right  "><!--right-->
        <li class="items"><span class="label-position due">{{due}}</span></li>
        <li><span class="label label-info items priority-position {{priority}}"
                  id="{{priority}}">{{priority}}</span></li>
        <li>
            <button type="button" class="label label-info  trash js-delete-task"><span
                    class="glyphicon glyphicon-remove"></span></button>
        </li>
    </div>
    <!--<div class="clear"></div>-->
</div>

And here is the helper for the template:

 items: function() {
    var priority = $("#priority_sorter").val();

    /// TODO fix so this can be sorted by 'completed' as well

    var priority_val = Session.get('priority');
    var user = Meteor.user()._id;
    /// Filter by Priority
    if (priority_val === "All Tasks") {
        //console.log("First IF priority set to ", priority_val);
        retu Items.find();

    } else {
        //console.log("Else statement priority value is "+ priority_val+ ". With User ID "+ user);
        retu Items.find({owner: user, "priority": priority_val}, {sort: {"created": -1}});
    }
},
isComplete: function(){
    var task = Items.thisId.checked;
    if(Items.thisId.checked === 'complete'){
        console.log("Checked confirmed for "+ task);
        $('.js-complete').wrap("<strike>");
    }
},

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 4 خرداد 1395 ساعت: 0:02

صفحه بندی