Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Kaz Baig
@kbaig
We at Angular 5 already now damn
alpox
@alpox
Angular 2/4 is still fine
@kbaig Well there's not much of a difference in those numbers
Kaz Baig
@kbaig
yeah ik
alpox
@alpox
@psilva00 Be aware that Angular and AngularJS are 2 totally different things
Even though they are made by (mostly) the same devs
Kaz Baig
@kbaig
Complete rewrite
P. Silva
@psilva00
Yeah, that I know.
I have yet to wrap my head around the ES 6 way of doing things though, to be honest.
Marius Nicolae
@bytao7mao
Hello guys, how should i avoid concatenation in append(jquery) when i click a button ?
Kaz Baig
@kbaig
@psilva00 In what sense
P. Silva
@psilva00
@kbaig, syntax and whatnot.
Kaz Baig
@kbaig
@bytao7mao append is to add to the html of an element. What are you trying to do?
alpox
@alpox
@bytao7mao Append pretty much means concat :D
Marius Nicolae
@bytao7mao
im using some code to get json text
when i click the button which is getting that text, it's concatenating
what should i use to avoid this
alpox
@alpox
@bytao7mao Another method than .append
Marius Nicolae
@bytao7mao
ok, which one
:)))
alpox
@alpox
@bytao7mao Depends on what you want to do exactly
Kaz Baig
@kbaig
@bytao7mao could you provide a code example? Not sure what you want to do instead
Marius Nicolae
@bytao7mao
sure
alpox
@alpox
Marius Nicolae
@bytao7mao
i want to return only once, and same result, not concatenating the same result
Kaz Baig
@kbaig
So then you would want to build your html in the loop, and use the html method outside of the loop
alpox
@alpox
@bytao7mao For the country as example:
<div class = "col-xs-12 alert message2">
        Your country: <span class="country"></span>
   </div>
#country { font-weight: bold; }
$("#country").text(json.countries[11]['name']);
@bytao7mao And what @kbaig tells you :-)
Actually, i wonder what you want to achieve with the loop
Kaz Baig
@kbaig
Ultimately he's using the loop to build his html
Probably more performant also to just concat the html string in the loop and call jQuery once after the loop
alpox
@alpox
@kbaig I see that, but still, does he want to add all countries? Or just one random one? One cannot be sure when he says he doesn't want to append
Naaman Saif
@Naaman-Saif
I have made the barebones for the pomodoro Clock can somebody help me with the Script? How do I get the Timer?
Kaz Baig
@kbaig
@alpox I think he wants to add all countries but if he clicks again, the same thing doesn't get added to the preexisting para
Try clicking the button more than once
alpox
@alpox
@Forlenza setInterval - or setTimeout
@kbaig Ah may be
So then he would need an accumulator or do a .empty before the loop and then use .append @bytao7mao
Kaz Baig
@kbaig

@alpox yeah then he could just do

$('.message').empty();
$('.message2').empty();

as his first 2 lines in the getJSON callback

alpox
@alpox
jup
Kaz Baig
@kbaig
That's the quickest but pretty imperative way
Marius Nicolae
@bytao7mao
empty() when ?
after append ?
alpox
@alpox
@bytao7mao before the for loop
Kaz Baig
@kbaig
first 2 lines of the callback
@bytao7mao The best solution to be honest though would be to just have a boolean that your click callback checks for before making the getJSON call
That way, you don't have to keep making a new request every time the user clicks, just the first time
Marius Nicolae
@bytao7mao
The empty method seems allright, the other method , to keep just a statement and get rid of Loop ?
Kaz Baig
@kbaig
what