Loading ...
Sorry, an error occurred while loading the content.

489Can't perform query or update using javascript variables

Expand Messages
  • commscheck
    Jul 14, 2014
    • 0 Attachment

      I have an HTML table of checkboxes. I am trying to set the "mixed" value in the database to true or false, depending on whether the corresponding checkbox is ticked or not. I'm using the below code:


      $('input:checkbox').on('change', function() {

          var val = $(this).val();

          var checked = $(this).is(':checked');

              

          recipes({id:val}).update({mixed:checked});

      }


      The 'val' and 'checked' variables are set correctly. For example they may contain '3' and 'true' respectively. However the update call isn't appears to do nothing. It does work if I replace recipes({id:val}) with recipes({id:0}) but will then only update the first record with the value of checked.


      I'm having a similar issue when I'm trying to get the values. Trying to do get the value with recipes({id:val}).first().mixed returns undefined, but recipes({id:0}).first().mixed gets the value of the first row correctly.


      Sorry if it's a really noob problem, I'm fairly new to javascript and my Google-fu hasn't worked for me so far. Thanks in advance!

        

    • Show all 2 messages in this topic