سؤال

I have a simple form in meteor which would help configure the execution of my custom application. This form receives two arguments, Username and Password.

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Execute my custom app</title>
</head>

<body>
  {{> configDetails}}
</body>

<template name="configDetails">
    <div class="container">
        <form class="form-signin" role="form" id="form-signin" >
            <div class="row">
                <div class="span3 offset"><input type="textBox" class="input-block-level" placeholder="User Name" ></div>
                <div class="span3 offset1"><input type="textBox" class="input-block-level" placeholder="Password" ></div>
            </div>                                                          
            <input class="btn btn-lg btn-primary" type="submit" style="display: block; width: 100%;"  id="submit"/>     
        </form>
    </div>
</template>

Now I want these values to be received on the server side so that I can run my external app using child_process and pass these values as arguments to the external app. How can I receive these value in the meteor server section:

if (Meteor.isServer) {
  //I intend to use child_process to run my external application here
}

If the values cannot directly be received in the server section, how can I receive them in client section and pass them onto server. I am having difficulties receiving them in client section as well:

if (Meteor.isClient) {

  Template.configDetails.events({
    'click input': function () {
      console.log( 'Submitting form!' );
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
        console.log("You pressed the button");
    }
  });

    Template.configDetails.events({
    'submit form': function( event ){   
      console.log( 'Submitting form!' );
      event.preventDefault();
      event.stopPropagation();
      return false; 
    }
  });

None of the above functions execute the console.log method. Any ideas what I am doing wrong. Let me know if you need further info.

هل كانت مفيدة؟

المحلول

In my projets I'm using smth like this:

Template.configDetails.events({
  "click #submit": function(e, t) {

    e.preventDefault();

    Meteor.call('someMethod', attributes, function(error, id) {
      if (error) {
        return console.log("Error..........");
      } else {
        //Do smth
      }
    });
  });

 }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top