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;








3















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.



enter image description here



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?










share|improve this question
























  • 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

















3















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.



enter image description here



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?










share|improve this question
























  • 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













3












3








3








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.



enter image description here



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?










share|improve this question
















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.



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












2 Answers
2






active

oldest

votes


















3














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.






share|improve this answer























  • 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


















0














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.






share|improve this answer























  • It's pointless to put anything after return.

    – Matt Komarnicki
    Jun 7 '16 at 0:51











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
);



);













draft saved

draft discarded


















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









3














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.






share|improve this answer























  • 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















3














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.






share|improve this answer























  • 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













3












3








3







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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













0














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.






share|improve this answer























  • It's pointless to put anything after return.

    – Matt Komarnicki
    Jun 7 '16 at 0:51















0














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.






share|improve this answer























  • It's pointless to put anything after return.

    – Matt Komarnicki
    Jun 7 '16 at 0:51













0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 6 '16 at 9:44









Luis GarLuis Gar

144214




144214












  • 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
















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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived