我有这个助手,有时第一次调用它两次,第二次未定义 slug 没关系,如何防止助手被调用两次?
shareurl: ->
console.log "helper"
campId = Session.get('campaign_id')
Meteor.call 'getCampaignSlug', campId, (e, resp) ->
console.log e if e
console.log resp
slug = resp[0]
campaignId = resp[1]
Session.set('slug' + campId, slug)
slug = Session.get('slug' + campId)
#slug = "test"
console.log Meteor.absoluteUrl "" + Meteor.user()._id + '/' + slug
return Meteor.absoluteUrl "" + Meteor.user()._id + '/' + slug
在模板中它被调用了一次。但在控制台中我看到它有时被调用了两次。
<button class="btn btn-primary pull-right draft-send mr10" type="button" data-shareurl="{{shareurl}}" data-step="1" data-intro="Click here to send your campaign" data-position="left">Send</button>