yogiben / meteor-autoform-modals

Adds modals to insert/update/delete Meteor collections
63 stars 41 forks source link

Calling from within table view where I have to compute _id via DOM access, how? #44

Open ssteinerx opened 9 years ago

ssteinerx commented 9 years ago

I can only figure out which record I'm editing by calling a function that traverses the DOM.

How can I get that function injected to provide context for the form?

pbibalan commented 8 years ago

+1

pbibalan commented 8 years ago

This might help:

Template.afModal.events
  'click *': (e, t) ->
    e.preventDefault()
    if (t.data.formId == "itemForm")
      Session.set 'itemId', t.parent().parent().data._id

The you can access the session variable in your auto form hook.

AutoForm.hooks 
  itemForm: 
    before: insert: (doc, template) ->
      doc.itemId = Session.get('itemId')
      doc