[SOLVED] Quick autoform question


#1

For a schema that’s defined a slug, and on submit the slug has been set to an autoValue og slugifying the title. Is there some way to add this behaviour to the actual form submitting process instead? Eg. an input field being automatically filled with a value based off of input in the title field?


#2

For those who are wondering how this can be solved easily, in my case where I wanted slugs automated but editable, the easiest thing to do is just not use autoValue (since this happens server-side) and rather just use Meteors handy keyup, keydown or keypress events and bind it to changes for the field you want to base the slug off of and then just set the value to the field you want slugified, as such:

Template.showSubmit.events({
  "keyup #showSubmit input[name=name]": function(e, template) {
    // slugify name
    var nameValue = $('[name=name]').val().toLowerCase();
    var slug = _.slugify(nameValue);

    // set default slug
    $('[name=slug]').val(slug);
  }
});

#3

Thanks for posting the follow-up!