|
If you want someone to help fix your code, then you need to show us the relevant parts of your code, and explain what the problem is.
On the other hand, if you were expecting someone to write the code for you, then you've come to the wrong site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello, I have a problem that's been racking my brain for a while now. I have drop-down navigation that I would like closed when I click on an href link. My code works fine if viewed in a desktop but it's in mobile I have problems. If links are clicked that are within my site, the links will be followed, but the menu will not close, however any links that are not on my domain will act fine, the menu will close and the link will be followed. This happens only on mobile. This has been stopping me from opening my site for a while so any help is greatly appreciated.
//JS
<pre>jQuery(document).ready(function($){
var MQL = 1170;
if($(window).width() > MQL) {
var headerHeight = $('.cd-header').height();
$(window).on('scroll',
{
previousTop: 0
},
function () {
var currentTop = $(window).scrollTop();
if (currentTop < this.previousTop ) {
if (currentTop > 0 && $('.cd-header').hasClass('is-fixed')) {
$('.cd-header').addClass('is-visible');
} else {
$('.cd-header').removeClass('is-visible is-fixed');
}
} else {
$('.cd-header').removeClass('is-visible');
if( currentTop > headerHeight && !$('.cd-header').hasClass('is-fixed')) $('.cd-header').addClass('is-fixed');
}
this.previousTop = currentTop;
});
}
$('.cd-primary-nav-trigger').on('click', function(){
$('.cd-menu-icon').toggleClass('is-clicked');
$('.cd-header').toggleClass('menu-is-open');
if( $('.cd-primary-nav').hasClass('is-visible') ) {
$('.cd-primary-nav').removeClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
$('body').removeClass('overflow-hidden');
});
} else {
$('.cd-primary-nav').addClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
$('body').addClass('overflow-hidden');
});
}
});
});
$('.cd-primary-nav li a').on('click', function(event){
var href = $(this).attr('href');
event.preventDefault;
$('.cd-menu-icon').removeClass('is-clicked');
$('.cd-header').removeClass('menu-is-open');
$('.cd-primary-nav').removeClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
$('body').removeClass('overflow-hidden');
document.location = href;
});
});
//HTML
<pre> <header class="cd-header">
<div class="cd-logo"><img src="img/cd-logo.svg" alt="Logo"></div>
<a class="cd-primary-nav-trigger" href="#0">
Menu
</a>
</header>
<nav>
<ul class="cd-primary-nav">
<li class="cd-label">About us</li>
<li><a href="http://mysite.com">Home</a></li><pre><!--<pre>
Our services
<!-- This link will work fine because it's not on my domain. -->
|
|
|
|
|
please discuss how browser javascript engine parse and execute javascript.
i heard modern browser use compiler too to execute js....is it true?
please tell me how javascript v8 engine works.
if i am asking broad question which can not be discuss here then redirect me to few good article from where i will get answer for my questions like above. thanks
|
|
|
|
|
Mou_kol wrote: please discuss how browser javascript engine parse and execute javascript. It is interpreted by the JavaScript engine, how it is done depends on the how the JavaScript engine was written. Different engines have their own different implementation of everything here. Edge came out with a different engine that Internet Explorer (which I doubt, actually), called Chakra. You can read the code of Chakra here on GitHub to learn more on how does that engine work, GitHub - Microsoft/ChakraCore: ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge
Mou_kol wrote: i heard modern browser use compiler too to execute js....is it true?
please tell me how javascript v8 engine works. You might have heard about the way Google translates JavaScript to C++ and then compiles it down to run it natively. I am unsure of what that post actually meant, but it had something to do with the performance of the JavaScript, by converting the "interpreted" language to "compiled" language. Maybe, that doesn't work in a web application, or is only for Chromium platforms or Android stuff. Totally unsure of this case.
Chrome V8 | Google Developers
c++ - Which Javascript engine would you embed in your application? - Stack Overflow (Read this thread for some more insights as to how Mozilla and Google's JavaScript work, for compiling the JavaScript.
Mou_kol wrote: if i am asking broad question which can not be discuss here then redirect me to few good article from where i will get answer for my questions like above. thanks The top right corner has a search, it will answer all the questions easily. Otherwise, Google would suffice.
Typically saying, an article which I am going to suggest may or may not help you, thus asking you to help yourself.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
thanks a lot for your answer and suggestion
|
|
|
|
|
can i implement a school management system that does lots of mathematical manipulations using java script??
|
|
|
|
|
Probably not. The fact that you are asking this question suggests that you do not have a lot of experience in Javascript. Otherwise you would realise that Javascript alone is not enough for such a project.
|
|
|
|
|
You could but would likely not want to.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Although it's been a while since your post, the following will help: W3Schools Online Web Tutorials[^]
First you need to learn HTML so you can make a web page
Next, CSS so you can make it look pleasant and put things where you need them
Finally, you can learn javaScript to bring some life to your page (math, etc.)
For some reason, it's a common belief that anyone can just sit down and write a program. Books like "PHP in 24 hours", for example. It just isn't so. It takes work, practice, learning.
You can be self-taught - a very large proportion of professional programmers are - but that often follows years of doing it for fun, often starting at a very early age. Self taught programmers usually have a particular passion for the craft and make some of the most amazing stuff.
I used the above site to learn HTML, CSS, javaScript and PHP (already knew SQL and already knew how to program). It's a major piece of the day-to-day operations of a $US 400 million company. It can be done - but it takes time.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
hy I have typescript app with angular4. I use routers to navigate on pages. I use activatedroute in the code:
ngOnInit(): void {
this.activatedRoute.params.subscribe((parms: any) => {
if (parms.lang) {
this.loading = true;
this.http._get(GLOBALS.url+"/api/GetPageHTML/Page2/"+parms.lang).subscribe(data => this.pageHTML = data[0]['puslHTML']);
} else {
this.loading = true;
this.http._get(GLOBALS.url+"/api/GetPageHTML/Page2/"+parms.lang).subscribe(data => this.pageHTML = data[0]['puslHTML']);
}
});
}
Is it possible to go to the same page again?
parms.lang is here for checking wheater is there request to change language.
|
|
|
|
|
I am not sure why is there even a condition, when both the blocks contain same code to be executed. Both set loading to true and have a same code to execute, then why check it?
Also, which page are you talking about? Some page in the history, otherwise you will require to pass in a parameter that holds the reference or URL to the page. Also, did you try using this.location.back(); , which used to work in Angular2 not sure if they changed it.
angular2 routing - How to go back last page in Angular 2 - Stack Overflow
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hy,
there are two blocks with same code because this is a way I check whether visitor changed the language of website. I have two navs ir my website: one stands for menu and the other for languages. So in my langs bar I must have links with
routerLinks which have additional parameter "!":
<a [routerLink]="['/'+currPage,'!']" (click)="changeLang('en')">EN</a>
when the user clicks on selected language because the
ActivedRouter only works if I apply to same component with different parameters.
This is why my language bar`s links routerLinks contain additional parameters, while the main menu doesn`t.
But this is a offtopic problem, though it is absolutely related with topic.
I didn`t try any
this.location.back() because I try to find the solution which is more close to Rounting rather to history as I would like my user to be visiting the page using buttons and links. And I wonder where should I place
this.location.back() in the code because I would like to go to same page using same link?
|
|
|
|
|
So, I've spent most of my professional career working on system administration, databases, and desktop applications. Now I find myself being thrust into ASP.Net Web Api 2 to build REST interfaces so that an internet portal can access internal data via IIS.
I've got the server side down pretty good so my question is do I spend more time focusing on learning the ins and outs of JavaScript or TypeScript or both for the client side?
As a C# dev, the type safety and classes of TypeScript are appealing but it doesn't seem to support the breadth of ECMAScript capabilities like JavaScript does. I want to focus on what will work best but I don't want to bind my hands either. Since this is really my first serious foray into browser scripting, I wanted to get the opinion of the CPians that more experienced in such matters.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
TypeScript is the way to go. It would be more sensible coming from the C# dev background to have the structured code even in JavaScript world which is highly loose scripting language but with huge power.
|
|
|
|
|
Thanks. I thought that TypeScript would give me a little more piece of mind. Before getting started on that I'm reviewing this: ECMAScript Specifications[^]. I think that I need to build a strong foundation before attempting to build a house.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
I've never used TypeScript so I can't speak to that. I use jQuery a ton. It makes using JavaScript much easier.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
My viewpoint is that these super-sets (TS, CS, DART, etc) compile to JavaScript. If JS itself were so tedious or difficult to work in I would understand that, but largely it doesn't make sense to me to add a link in a chain that already uses a high-level language. It's great for someone who doesn't have the interest or capacity to learn how the underlying technology works, but doesn't really benefit someone that's willing to dig in.
That said, the ECMA approach to OOP is pretty damn counter-intuitive to the C# mindset and there is a bit of a curve. I like that personally, because the switching of gears makes defining client-vs-server concerns fairly obvious, but I may be alone in that regard.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
These are good points. The ECMA Standard and JavaScript is still the foundation of all the web scripting libraries so I see how working toward a professional level familiarity with it would be beneficial. It's similar to how Assembler is still the foundation of all of the programing languages. Does C# make programing a lot easier? Yes. Does is still end up as assembly instructions passed to the interpreter? Of course. C# and the rest of the high-level languages just make it easier to program, abstracting all the tedious bits. I may not be able to write a full program in x86 or x64 assembly (yet) but I know it works and that knowledge helps me write better code at the higher levels.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
Type script is a JavaScript inspired object oriented language that compiles to JavaScript.
At the end - in the browser - it is always JavaScript for now, so I would say: learn JavaScript inside-out...
After that, you may find it easier to use some intermediate - like TypeScript - to create the actual JavaScript code, but that's secondary...
If you are coming from the intermediate part only, you will find yourself helpless against a on-client-machine-only bug, that will force you to debug the JavaScript result (and generated code is always hard to read)...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I am beginning to believe that I will be better off just biting the bullet and learning more JavaScript. Any good resources to learn some of the intermidiate to advanced topics? I've got the internet (ecma-international.org, w3.org, w3schools.com) that have gotten me a good start as well as a book on JavaScript and JQuery. What I am looking for is a resource that tells me all the things I can do with JavaScript and a few pointers to get me started. So far, I'm learning how to manipulate the DOM and using XMLHttpRequest to do a little async processing from an MVC/WebApi test site that I built. Obviously, there's a lot you can do with it but nothing I can find paints a good road map on what subjects to focus on and in what order.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
|
Thanks. This should help a bit. Before I start relying on libraries I want to know how they work.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
The question is how deep a rabbit hole you are planning to follow. If your intention is to learn enough to do a project and will not become full time web developer, then TypeScript is probably easier. If you want to switch from being SysAdmin into a developer then I would suggest biting the bullet and get to know JS. I personally know JS then learn TS, then gone back to stick with JS. TS to JS is like C/C++ to Assembler.
|
|
|
|
|
|
i search a lot for example which i can run and see that angular service and factory is singleton in nature because i heard many time that these are singleton in nature when i read many write up on difference between service and factory but none one show this that these are singleton with example and code.
i am new in angular. so very curious to know how could i write a program which tell me that service and factory is singleton. if possible please provide a example.
sample service and factory
var myApp = angular.module('myApp', []);
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!";
};
});
myApp.factory('helloWorldFromFactory', function() {
return {
sayHello: function() {
return "Hello, World!";
}
};
});
thanks
|
|
|
|