Foundation.MediaQuery.current in a loop (first iteration always shows nothing, next are always correct)How to skip to next iteration in jQuery.each() util?Format number to always show 2 decimal placesjavascript arrays in and outside of functions$location not working in AngularJS using d3.jsappending with .each and getting values on next looping jqueryFirst comment posted(appended) always remains on topiterate through JSON object with pause before next iterationAngularJS - First run of .service plans to send data, but none shows, second run, no plans to send data, but some showsJquery hover function works only on page reload - chrome extensionHow to iterate an array in javascript, with promises inside the loop block and wait for all promises to be completed to continue
strToHex ( string to its hex representation as string)
Risk of getting Chronic Wasting Disease (CWD) in the United States?
Which models of the Boeing 737 are still in production?
Why are electrically insulating heatsinks so rare? Is it just cost?
How does one intimidate enemies without having the capacity for violence?
What's the output of a record cartridge playing an out-of-speed record
Is a tag line useful on a cover?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
The use of multiple foreign keys on same column in SQL Server
Can divisibility rules for digits be generalized to sum of digits
An academic/student plagiarism
Email Account under attack (really) - anything I can do?
If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?
How does strength of boric acid solution increase in presence of salicylic acid?
To string or not to string
Mathematical cryptic clues
Why Is Death Allowed In the Matrix?
Is it important to consider tone, melody, and musical form while writing a song?
What are the differences between the usage of 'it' and 'they'?
Test whether all array elements are factors of a number
What typically incentivizes a professor to change jobs to a lower ranking university?
Problem of parity - Can we draw a closed path made up of 20 line segments...
LaTeX closing $ signs makes cursor jump
Minkowski space
Foundation.MediaQuery.current in a loop (first iteration always shows nothing, next are always correct)
How to skip to next iteration in jQuery.each() util?Format number to always show 2 decimal placesjavascript arrays in and outside of functions$location not working in AngularJS using d3.jsappending with .each and getting values on next looping jqueryFirst comment posted(appended) always remains on topiterate through JSON object with pause before next iterationAngularJS - First run of .service plans to send data, but none shows, second run, no plans to send data, but some showsJquery hover function works only on page reload - chrome extensionHow to iterate an array in javascript, with promises inside the loop block and wait for all promises to be completed to continue
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I use Foundation.MediaQuery.current
to determine current breakpoint. Every time I call console.log(Foundation.MediaQuery.current)
for the first time (n=0) I get nothing.
For all next calls (n>0) I always get correct breakpoint, let's say large
.
This is my function:
_calculateLimit = function ()
var postsInjectedCount = container.find('.post-appended').length;
console.log(Foundation.MediaQuery.current);
if (Foundation.MediaQuery.current === 'large') // gives nothing on first iteration :/
return postsInjectedCount % 3 !== 0 ? 2 : 3;
return postsInjectedCount % 2 !== 0 ? 1 : 2;
,
Below picture shows a screen from my Chrome Dev Tools.
Helpful info 1: There is no difference in terms of business logic between first call and next calls.
Helpful info 2: I use Foundation For Sites ~6.2.1
What am I doing wrong?
javascript jquery zurb-foundation zurb-foundation-6
add a comment |
I use Foundation.MediaQuery.current
to determine current breakpoint. Every time I call console.log(Foundation.MediaQuery.current)
for the first time (n=0) I get nothing.
For all next calls (n>0) I always get correct breakpoint, let's say large
.
This is my function:
_calculateLimit = function ()
var postsInjectedCount = container.find('.post-appended').length;
console.log(Foundation.MediaQuery.current);
if (Foundation.MediaQuery.current === 'large') // gives nothing on first iteration :/
return postsInjectedCount % 3 !== 0 ? 2 : 3;
return postsInjectedCount % 2 !== 0 ? 1 : 2;
,
Below picture shows a screen from my Chrome Dev Tools.
Helpful info 1: There is no difference in terms of business logic between first call and next calls.
Helpful info 2: I use Foundation For Sites ~6.2.1
What am I doing wrong?
javascript jquery zurb-foundation zurb-foundation-6
are you adding this code, after Foundation init code?
– Shoaib Iqbal
Jun 6 '16 at 10:09
Hi @ShoaibIqbal, you were right. I did call parent function before initiating Foundation. Please write your comment as an answer, so I will mark it as accepted.
– Matt Komarnicki
Jun 6 '16 at 12:15
add a comment |
I use Foundation.MediaQuery.current
to determine current breakpoint. Every time I call console.log(Foundation.MediaQuery.current)
for the first time (n=0) I get nothing.
For all next calls (n>0) I always get correct breakpoint, let's say large
.
This is my function:
_calculateLimit = function ()
var postsInjectedCount = container.find('.post-appended').length;
console.log(Foundation.MediaQuery.current);
if (Foundation.MediaQuery.current === 'large') // gives nothing on first iteration :/
return postsInjectedCount % 3 !== 0 ? 2 : 3;
return postsInjectedCount % 2 !== 0 ? 1 : 2;
,
Below picture shows a screen from my Chrome Dev Tools.
Helpful info 1: There is no difference in terms of business logic between first call and next calls.
Helpful info 2: I use Foundation For Sites ~6.2.1
What am I doing wrong?
javascript jquery zurb-foundation zurb-foundation-6
I use Foundation.MediaQuery.current
to determine current breakpoint. Every time I call console.log(Foundation.MediaQuery.current)
for the first time (n=0) I get nothing.
For all next calls (n>0) I always get correct breakpoint, let's say large
.
This is my function:
_calculateLimit = function ()
var postsInjectedCount = container.find('.post-appended').length;
console.log(Foundation.MediaQuery.current);
if (Foundation.MediaQuery.current === 'large') // gives nothing on first iteration :/
return postsInjectedCount % 3 !== 0 ? 2 : 3;
return postsInjectedCount % 2 !== 0 ? 1 : 2;
,
Below picture shows a screen from my Chrome Dev Tools.
Helpful info 1: There is no difference in terms of business logic between first call and next calls.
Helpful info 2: I use Foundation For Sites ~6.2.1
What am I doing wrong?
javascript jquery zurb-foundation zurb-foundation-6
javascript jquery zurb-foundation zurb-foundation-6
edited Mar 9 at 2:14
Matt Komarnicki
asked Jun 6 '16 at 9:14
Matt KomarnickiMatt Komarnicki
2,25431943
2,25431943
are you adding this code, after Foundation init code?
– Shoaib Iqbal
Jun 6 '16 at 10:09
Hi @ShoaibIqbal, you were right. I did call parent function before initiating Foundation. Please write your comment as an answer, so I will mark it as accepted.
– Matt Komarnicki
Jun 6 '16 at 12:15
add a comment |
are you adding this code, after Foundation init code?
– Shoaib Iqbal
Jun 6 '16 at 10:09
Hi @ShoaibIqbal, you were right. I did call parent function before initiating Foundation. Please write your comment as an answer, so I will mark it as accepted.
– Matt Komarnicki
Jun 6 '16 at 12:15
are you adding this code, after Foundation init code?
– Shoaib Iqbal
Jun 6 '16 at 10:09
are you adding this code, after Foundation init code?
– Shoaib Iqbal
Jun 6 '16 at 10:09
Hi @ShoaibIqbal, you were right. I did call parent function before initiating Foundation. Please write your comment as an answer, so I will mark it as accepted.
– Matt Komarnicki
Jun 6 '16 at 12:15
Hi @ShoaibIqbal, you were right. I did call parent function before initiating Foundation. Please write your comment as an answer, so I will mark it as accepted.
– Matt Komarnicki
Jun 6 '16 at 12:15
add a comment |
2 Answers
2
active
oldest
votes
It looks like you are running the code before Foundation has initialized. It is a good practice to put the init code at the top of JavaScript file.
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after$(document).foundation();
and now everything works. Thank you very much.
– Matt Komarnicki
Jun 6 '16 at 12:20
add a comment |
You will see it better if put the console.log at the end of the function. So try it and just tell the results.
It will clarify where the error is.
It's pointless to put anything afterreturn
.
– Matt Komarnicki
Jun 7 '16 at 0:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37653593%2ffoundation-mediaquery-current-in-a-loop-first-iteration-always-shows-nothing-n%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It looks like you are running the code before Foundation has initialized. It is a good practice to put the init code at the top of JavaScript file.
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after$(document).foundation();
and now everything works. Thank you very much.
– Matt Komarnicki
Jun 6 '16 at 12:20
add a comment |
It looks like you are running the code before Foundation has initialized. It is a good practice to put the init code at the top of JavaScript file.
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after$(document).foundation();
and now everything works. Thank you very much.
– Matt Komarnicki
Jun 6 '16 at 12:20
add a comment |
It looks like you are running the code before Foundation has initialized. It is a good practice to put the init code at the top of JavaScript file.
It looks like you are running the code before Foundation has initialized. It is a good practice to put the init code at the top of JavaScript file.
answered Jun 6 '16 at 12:17
Shoaib IqbalShoaib Iqbal
1,108920
1,108920
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after$(document).foundation();
and now everything works. Thank you very much.
– Matt Komarnicki
Jun 6 '16 at 12:20
add a comment |
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after$(document).foundation();
and now everything works. Thank you very much.
– Matt Komarnicki
Jun 6 '16 at 12:20
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after
$(document).foundation();
and now everything works. Thank you very much.– Matt Komarnicki
Jun 6 '16 at 12:20
Thanks Shoaib. That helped me. I was indeed calling my function before initiating Foundation. However I left that in footer, I just moved my method after
$(document).foundation();
and now everything works. Thank you very much.– Matt Komarnicki
Jun 6 '16 at 12:20
add a comment |
You will see it better if put the console.log at the end of the function. So try it and just tell the results.
It will clarify where the error is.
It's pointless to put anything afterreturn
.
– Matt Komarnicki
Jun 7 '16 at 0:51
add a comment |
You will see it better if put the console.log at the end of the function. So try it and just tell the results.
It will clarify where the error is.
It's pointless to put anything afterreturn
.
– Matt Komarnicki
Jun 7 '16 at 0:51
add a comment |
You will see it better if put the console.log at the end of the function. So try it and just tell the results.
It will clarify where the error is.
You will see it better if put the console.log at the end of the function. So try it and just tell the results.
It will clarify where the error is.
answered Jun 6 '16 at 9:44
Luis GarLuis Gar
144214
144214
It's pointless to put anything afterreturn
.
– Matt Komarnicki
Jun 7 '16 at 0:51
add a comment |
It's pointless to put anything afterreturn
.
– Matt Komarnicki
Jun 7 '16 at 0:51
It's pointless to put anything after
return
.– Matt Komarnicki
Jun 7 '16 at 0:51
It's pointless to put anything after
return
.– Matt Komarnicki
Jun 7 '16 at 0:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37653593%2ffoundation-mediaquery-current-in-a-loop-first-iteration-always-shows-nothing-n%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you adding this code, after Foundation init code?
– Shoaib Iqbal
Jun 6 '16 at 10:09
Hi @ShoaibIqbal, you were right. I did call parent function before initiating Foundation. Please write your comment as an answer, so I will mark it as accepted.
– Matt Komarnicki
Jun 6 '16 at 12:15