viewmodel icon indicating copy to clipboard operation
viewmodel copied to clipboard

false for attribute

Open frankapimenta opened this issue 8 years ago • 4 comments

When I have in the vm an attribute 'show' with default: true it should be true When I set it to false It should be false

this scenario does not pass to me... if I do: template.viewmodel.show(false) in an event the show attribute does not change! if I do it in the browser console (after logging the vm) it works.

is this a bug?

frankapimenta avatar Nov 29 '16 14:11 frankapimenta

What do you mean you do it in an event? Show me the code.

On Nov 29, 2016 7:43 AM, "Frank Pimenta" [email protected] wrote:

When I have in the vm an attribute 'show' with default: true it should be true When I set it to false It should be false

this scenario does not pass to me... if I do: template.viewmodel.show(false) in an event the show attribute does not change! if I do it in the browser console (after logging the vm) it works.

is this a bug?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/280, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31j5q2Elcjuu0WtS3oss8PS211ns1ks5rDDoWgaJpZM4K_DKN .

ManuelDeLeon avatar Nov 29 '16 14:11 ManuelDeLeon

Template.file.viewmode({
  hasFile: false,
  autorun() {
    this.hasFile(!!this.data().file); // here it sets to true
  },
  events: {
    'click a.delete-file'(event, template) {
      event.preventDefault();
      
      Meteor.call('deletefile', this.data().file._id, (err, response) => {
         if(response) {
           this.hasFile(false); // it does not set hasFile to false
         } else {
           // alert
           console.log(err);
         }
      });
    }
  }
}

frankapimenta avatar Nov 29 '16 15:11 frankapimenta

Does it work without the autorun?

On Nov 29, 2016 8:05 AM, "Frank Pimenta" [email protected] wrote:

Template.file.viewmode({ hasFile: false, autorun() { this.hasFile(!!this.data().file); // here it sets to true }, events: { 'click a.delete-file'(event, template) { event.preventDefault();

  Meteor.call('deletefile>', this.data().file._id, (err, response) => {
     if(response) {
       this.hasFile(false); // it does not set hasFile to false
     } else {
       // alert
       console.log(err);
     }
  });
}

} }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/280#issuecomment-263594567, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31tcKbkEB8HNZW3cgngcwMmGD0OmDks5rDD9IgaJpZM4K_DKN .

ManuelDeLeon avatar Nov 29 '16 15:11 ManuelDeLeon

Yes. Manuel. It works fine. After trying it I found out it was my issue. Thank you for the support :)

frankapimenta avatar Nov 29 '16 16:11 frankapimenta