Saturday 15 February 2014

jquery - Meteor: working with popups & modals -



jquery - Meteor: working with popups & modals -

i have template represents corporate article.

<template name="articledetail"> <section class="articles"> {{#with articledata}} <article> <div> <div> <div class="logo">{{logo}}</div> <div class="name">{{name}}</div> </div> </div> </article> {{/with}} </section>

this template receives info helper:

template.articledetail.articledata = function(){ homecoming articledb.findone({_id:session.get("clickedonarticle")}) }

an article displayed popup. when user clicks on article (from list of articles) detail article (template above) shown display:block.

i utilize event that:

template.articleoverview.events({ "click .article":function(event, template){ session.set("clickedonarticle", event.currenttarget.getattribute("data-article-id")) $(".adarticle").addclass("active") } })

the problem have click 2 times on article.

the first click injects template dom the sec click adds class "active".

what doing wrong here?

thx,

the solution rather simple:

the {{#with articledata}} block false, html of template not rendered page.

when clicked on article {{#with articledata}} returned true (because there info within it) had click sec time jquery fire (to add together class .active).

so key adarticles template in page on load , not on click. returned true if query db returned false.

template.adarticles.articledata = function(){ homecoming tikidb.findone({_id:session.get("clickedonarticle")}) || true }

so thing changed || true bit , works expected. wonder if there solution this.

jquery templates meteor addclass

No comments:

Post a Comment