Posts

javascript - Using JQuery to inject an ejs template into html -

can html ejs template injected via jquery? i have index file has navbar , content area, sample testbutton template trying render. index.ejs <ul> . . <li id="listitem"><a href="#test_page">nav bar item</a></li> </ul> <div id="display"> </div> <script> $('#listitem').click( function(){ // note - testbuttontemplate being passed in routes $('#display').html( <%- render( testbuttontemplate, {} ) %> ); }); </script> testbutton.ejs: <a href="#" class="btn btn-primary" id="test-button"> click me! </a> i did best simplify code, basically, when click on link nav bar, want dynamically load page in display div. the nav bar works. click functionality works. if manuallay display ejs template in div, works. ex: <div id="display"> <%- render( testbuttontemp...

android - SharedPreferences from one Fragment isn't registering data for a Login Activity on another Fragment -

i have fragment called loginfragment through user can register first time clicking on register button. upon clicking button new fragment, called registerfragment, opens user chooses , enters new username , password registered. when run app , enter fields under register , select ok, shows "saved info" in toast it's supposed to. when try logging in using username , password registered for, app doesn't recognize info , displays toast "please check entries , try again" should displayed when username exists or password incorrect, in case not case. is sharedpreferences not saving username , password values because working 2 different fragments? appreciated! registerfragment.java public class registerfragment extends fragment { button register_btn; edittext username_signup_et, password_signup_et; private string key_uid = "uid"; private string key_password = "pwd"; private final string prefer_name = "reg...

java - Argument state after the thread is completed -

question: suppose pass arraylist runnable constructor. in runnable class add strings list. run thread main() , wait completion. after thread execution over, possible when iterate list in main() strings(values) added list runnable class because reference arraylist created in heap. when iterate list, empty. explain why list empty. thanks in advance: vijay k public class getlistthread implements runnable{ private list<string> names; public getlistthread(list<string> names) { super(); this.names = names; } @override public void run() { for(int i=0;i<4;i++){ try { names.add(threadlocalrandom.current().nextint(1,10) + "a"); thread.sleep(2000); } catch (interruptedexception e) { e.printstacktrace(); } } //system.out.println(names); } } public class testthread { public static void main(string[] args) { list<string> names = new arraylist<string>(); get...

Where to make http request for every route in angularjs? -

suppose web app needs make http request site title, site description , on. since these variables common pages, makes sense request every time user enter site. the question is, make calls? in run block? or create root controller these tasks? you can use 1 of these 2 approaches: make call in run block , store value in $rootscope , use anywhere want, in states, use resolve page title , details , , in views , ease use resolve in root state , use resolved variable dependency in other child or sibling routes values.. $stateprovider.state('root', { resolve:{ // example using function simple return value. promiseobj: function($http){ // $http returns promise url data return $http({method: 'get', url: '/someurl'}); } }) .state('sibling',{ controller:function($scope,promiseobj){ $scope.title = promiseobj.title; } })

arrays - Converting strings to uppercase to compare with user input in C -

i attempting create program allow user search name in file. program successfully, occurred me not type in name capitalized in file. is, may search "sarah," name listed "sarah" in file name not found. around have attempted convert both strings upper case @ time of comparison. very, new teaching myself c, not if heading in right direction. @ point cannot program compile getting 2 errors "array initializer must initializer list or string literal." i'm assuming mean syntax not invalid in wrong direction. best way approach goal? #include <stdio.h> #include <ctype.h> #include <string.h> int main(void) { file *infile; infile = fopen("workroster.txt", "r"); char rank[4], gname[20], bname[20], name[20]; printf("enter name: __"); scanf("%s", name); int found = 0; while(fscanf(infile, "%s %s %s", rank, bname...

shell - How to capture a process Id and also add a trigger when that process finishes in a bash script? -

i trying make bash script start jar file , in background. reason i'm using nohup . right can capture pid of java process need able execute command when process finishes. this how started nohup java -jar jarfile.jar & echo $! > conf/pid i know this answer using ; make command execute after first 1 finishes. nohup java -jar jarfile.jar; echo "done" echo "done" example. problem don't know how combine them both. if run echo $! first echo "done" executes immediately. while if echo "done" goes first echo $! capture pid of echo "done" instead of 1 of jarfile. i know achieve desire functionality polling until don't see pid running anymore. avoid as possible. you can use bash util wait once start process using nohup nohup java -jar jarfile.jar & pid=$! # getting process id of last command executed wait $pid # waits until process mentioned pid complete echo "done, execute new c...

Ember.js - Can the root url link to two routes, one for authenticated users and one for guests? -

is possible root path, example.com , display landing page( application/index ) not logged in users profile page ( users/show ) users logged in? guest user -> example.com -> application/index authenticated user -> example.com -> users/show i know goes against ember's philosophy of app state being reflected url, still, know if/how situation possible? cheers! yes, can it. firstly, should check user logged in or not in "beforemodel" of "application" route. if user logged in transits "profile" page using "transitionto" method otherwise transits "login" page. beforemodel: function(transition) { var user; //put here method check if user logged in or not if (!user) { //if no user transist login this.transitionto('login'); } else { //other wise profile page this.transitionto('profilepage'); } }