Code Monkey home page Code Monkey logo

Comments (7)

aldeed avatar aldeed commented on May 21, 2024

Was this in an autoform? With which browser? Can you provide an example of a schema and form that shows the issue? I'm having trouble identifying which code might be at fault.

from meteor-collection2.

aldeed avatar aldeed commented on May 21, 2024

Are you using a placeholder shim? Perhaps that is setting the value to emulate placeholder in an older browser. Placeholder shims are probably incompatible with autoform unless they do some sort of transparent overlay that doesn't affect the value attribute.

from meteor-collection2.

coleerikson avatar coleerikson commented on May 21, 2024

I'm not using autoform. Just SS & C2. I've only checked in Chrome. I wasn't using a shim. Just the native placeholder HTML5 attribute. Like this:

input name="zipcode" type="text" class="form-control" value="{{zipcode}}" placeholder="Enter a Zip Code"

The form was erroring on the state and zip code fields which totally makes sense. Since I have an exact character count on state which is 2 and the state placeholder was longer. Also, zip code, which is 5 to 11 chars, but the placeholder has "Enter a Zip Code" which is obviously longer.

Here's the schema:
Properties = new Meteor.Collection2('properties', {
schema: {
name: {
type: String,
label: "Property Name",
min: 1
},
address: {
type: String,
label: "Address",
min: 1
},
city: {
type: String,
label: "City",
min: 1
},
state: {
type: String,
label: "State",
min: 2,
max: 2
},
zipcode: {
type: String,
label: "Zip Code",
min: 5,
max: 11
},
userId: {
type: String,
label: "User Id",
min: 6
}
}
});

from meteor-collection2.

aldeed avatar aldeed commented on May 21, 2024

What are you using to collect the values from the form inputs and create the update modifier? It seems like the error would lie in that code.

from meteor-collection2.

coleerikson avatar coleerikson commented on May 21, 2024

Template.propertyEdit.events({
'submit form': function(e){
e.preventDefault();

var property_details = {
  name: $(e.target).find('[name=name]').val(),
  address: $(e.target).find('[name=address]').val(),
  city: $(e.target).find('[name=city]').val(),
  state: $(e.target).find('[name=state]').val(),
  zipcode: $(e.target).find('[name=zipcode]').val()
}

Properties.update(this._id, {$set: property_details}, function(error,result){
  if(error){
    for(var i=0; Properties.simpleSchema().namedContext().invalidKeys().length > i; i++ ){
      throwError(Properties.simpleSchema().namedContext().invalidKeys()[i].message);
    }
  }else{
    alert("Property details updated");
    Router.go('propertyOverview', {_id: result});
  }
});

});

from meteor-collection2.

aldeed avatar aldeed commented on May 21, 2024

I feel like there must be some sort of jquery placeholder shim that you're not aware of. Try using template.find instead.

Template.propertyEdit.events({
  'submit form': function(e, template){
    e.preventDefault();

    var property_details = {
      name: template.find('[name=name]').value,
      address: template.find('[name=address]').value,
      city: template.find('[name=city]').value,
      state: template.find('[name=state]').value,
      zipcode: template.find('[name=zipcode]').value
    }
    ...
  }
});

from meteor-collection2.

coleerikson avatar coleerikson commented on May 21, 2024

I'll give it a go. Thanks Eric. The package is awesome btw.

from meteor-collection2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.