Posts

When and where may I load data, from a remote API, in my Ember.js application? -

i'm learning ember.js, , writing application want perform following tasks ... load data local storage check 3rd party api new additional data append additional , save entire thing local storage display table of data my application single route. i'm using ember.route 's model hook load data local storage. spot check 3rd party api new data, though? should in model hook? i'd able display sort of loading icon during query 3rd party api , i'm not sure if model hook allow me this? right now, route contains following code ... app.historyroute = ember.route.extend({ model: function (params) { // initialize model var model = { summoner: params, history: [] }; if (typeof(localstorage.history) == 'undefined') return model; // fetch data local storage var history = json.parse(localstorage.history); // check existing data if (!history.hasownkey(params.region) || !history[par...

Javascript object to PHP -

i posting javascript objects php backend not able retrieve data. i posted java-script object: {"name":"mastermold"} i trying access name this: $name= $_post["name"]; the error is: {"error":{"type":"errorexception","message":"undefined index: name","file":"c:\program files (x86)\ampps\www\app\controllers\journalscontroller.php","line":34}} savemongojournal=function(thejournal,dothis) { journalroute="http://localhost/public/journals" $http.post(journalroute,thejournal).success(dothis); }; $scope.clicky= function(){ savemongojournal( {name: "mastermold"},alertreply); }; $_post['name']; you may try (check this answer ) $data = json_decode(file_get_contents("php://input")); echo $data->name;

node.js - mongoose, how to create a schema has object in it? -

here's photoschema. has dbentry object. should create dbentry schema , ref in photoschema. or whatever have enough? new mongodb, try figure out correct way create schema. var photoschema = new mongoose.schema({ userid: objectid, type: string, createdon: {type: date, default: date.now}, isdeleted: {type: boolean, default: false}, isdownloaded: {type: boolean, default: false}, dbfile: string, dbentry: { revision: number, rev: string, thumb_exists: boolean, bytes: number, modified: date, client_mtime: date, path: { type: string, unique: true} } }); it depends on how plan access data. if want dbentry object each time query photoschema document, have way go. if however, you're going use dbentry independent of photoschema document, shoul...

javascript - preventDefault() won't work with form.submit() -

i'm trying login form either close lightbox, or change text of errorbox depending on whether or not login attempt success. i'm not sure, think has onclick="formhash(this.form, this.form.password);" which js function hashes password, continues form submit. ends with form.submit(); here's code: html: <form action="includes/process_login.php" method="post" name="login_form"> email: <input class="searchform" type="text" name="email" size="20"/><br /> password: <input class="searchform" type="password" name="password" id="password" size="20"/><br /> <input type="button" class="searchform" value="submit" size="40" style="height:45px; width:90px" onclick=...

yii - how to get one of the input textfield value through ajaxbutton -

how user's input value , submit ajax controller? right now, in controller says id undefined index in $_post['id'] this input textfield within form, kind of form inside form. <?php echo $form->textfield($model,'email',array('id'=>'email')); ?> <?php echo $form->error($model,'email'); ?> <?php echo chtml::ajaxbutton ( 'request code', chtml::normalizeurl(array('site/requestresetcode', 'render'=>true), array ( 'type' => 'post', //'data'=> array('id'=> 'js:$("#resetpasswordform_email").val()'), 'data'=> array('id'=> 'js:$("#email").val()'), 'success'=>'function(data){ if(data.status == "sent") ...

python - django __unicode__: \n and manytomany? -

class nickname(models.model): name = models.charfield() def __unicode__(self): return unicode(self.name) class bob(models.model): bob_nickname = models.manytomanyfield(nickname) def __unicode__(self): return unicode(self.bob_nickname) number1. how __unicode__ class bob display actual fk name, rather <django.db.models.fields.related.manyrelatedfieldsmanager object @ 0xdsfjk> ? edit : doing self.bob_nickname.all() seems work fine. aint pretty, displays info: [<nickname: ron>,<nickname: randy>] number2. also, how can def __unicode__ not escape \n ? i'd create multiline unicode string thank you! why don't use values_list related nick_names list? class bob(models.model): bob_nickname = models.manytomanyfield(nickname) def __unicode__(self): return u'\n'.join(self.bob_nickname.values_list('name', flat=true))

Writing data to a txt file file using java classes -

i trying understand why code not writing output textfile expect work. program takes filename command line argument, , prints text file screen. bit more complicated since uses classes , objects demonstrate how objects work. can decipher why not writing file? here's code:- public class mamoonp3test { public static void main(string[] args) throws exception { //create array of 10 guitar (mamoonp3) objects final int number_of_instances = 10; mamoonp3[] objectnames = new mamoonp3[number_of_instances]; try { string filename = new string(args[0]); for(int i=0; i<number_of_instances; i++) { objectnames[i] = new mamoonp3(filename); system.out.println("this guitar number: " + i); objectnames[i].tuneguitar(); objectnames[i].playguitar(); objectnames[i].displayacronym(); objectnames[i].stopguitar(); ...