Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR is not defined #28

Open
hvtor opened this issue Mar 24, 2015 · 1 comment
Open

SSR is not defined #28

hvtor opened this issue Mar 24, 2015 · 1 comment

Comments

@hvtor
Copy link

hvtor commented Mar 24, 2015

I'm getting an SSR is not defined uncaught reference error.

I've set up a template helper called sendUnits:
Template.EmailProperty.helpers({
sendUnits: function() {
var mailPropertyId = t.data._id;
return Units.findOne(mailPropertyId);
}
});

Uncaught ReferenceError: SSR is not definedEmailProperty.js?3d2014a058974929d3586076a654fdcac8d49b7d:22 Template.EmailProperty.events.click #submit-emailtemplate.js:278 (anonymous function)view.js:760 (anonymous function)view.js:414 Blaze._withCurrentViewview.js:759 (anonymous function)events.js:47 (anonymous function)jquery.js:4624 jQuery.event.dispatchjquery.js:4292 jQuery.event.add.elemData.handle

I have a server side template named : private/sendUnits.html

{{sendUnits}}

I have a click event handler:
/EmailProperty.js
'click #submit-email': function (e, t) {
e.preventDefault();
e.stopPropagation();
var mailTo = t.find(".mail-property").value;
var mailTo = '<' + mailTo + '>'
var mailPropertyId = t.data._id;

    $('#mail-form').slideUp(200);
    $('#mail-form').hide();
    $('#mail-button').slideDown(300);
    // attempted SSR.compileTemplate <-- same error as SSR.render
            var htmlText = SSR.compileTemplate('sendUnits', Assets.getText('sendUnits.html'));
    var htmlText = SSR.render('sendUnits', {propertyId: mailPropertyId});
    Meteor.call('sendUnitsEmail',mailTo,'<[email protected]>','Subject test',htmlText);
}

I have a server Meteor call:
/server.js

Meteor.methods({
        sendUnitsEmail: function (to, from, subject, htmlText) {

        var propertyId = Units.findOne(this.propertyId);
        console.log('sending unitsEmail');
        var htmlText = SSR.render("sendUnits", {propertyId: propertyId});
        console.log(htmlText);
        Meteor.Mandrill.send({
            to: to,
            from: from,
            subject: subject,
            text: htmlText
        });
    }
  });

I am unclear how to pass an ID from the client to the server, and then have it render a template with the helper 'sendUnits' and then have it respond with an email in rich HTML.

@ecwyne
Copy link

ecwyne commented Mar 30, 2015

@hvtor it looks like EmailProperty.js is client-side code. SSR only shows up on the server, you should not include SSR.compileTemplate('sendUnits', Assets.getText('sendUnits.html')); in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants