Slider breaks before loading - jquery-slider

Hi I am running WordPress latest version with a custom coded jQuery featured post slider in all pages. My problem is that the slides appears broken for 2 seconds when the page is loading, after the page is fully loaded it runs fine. If you wish you can have a look http://crunchmarketing.com.au/. Please help me out.

if you're using this (or similar) to execute the code:
$(function() {
$( "#slider" ).slider();
});
This is the same as:
$(document).ready(function () {
$("#slider").slider();
})
meaning the code wont execute until the page has loaded. It's the same with all jquery's functions, they are only loaded when the document has loaded completely.

Related

angular-ui-swiper: swiper is not defined

I am using the angular-ui-swiper and I want to set the active slide depending on the URL-Parameter. I have an angular controller, where the data is loaded for the swiper. This works fine, the buttons are working (prev, next). I call the method slideTo to set the activeslider after link click in the navigation. But it is not working if I load the page with the special parameter. The swiper-instance is not defined. So I have to call the correct page lifecycle event. I used the load, init-events, an equivalent to document ready, but without any success. It is only working if I put my setActiveSlide-Method to the scroll-event :D
Do you have any idea?
Thanks in advance
Maybe you need to make the set the activeslider in this kind of block:
angular.element(document).ready(function () {
//code here
});
Can you make a jsfiddle so we can see your code?

Material Design Lite rendering problems with Angular JS

I have some problems using Material Design Lite (getmdl.io). I followed the steps showed in the getmdl.io web in order to install it (actually I use bower), but I always have the same problem, when I change the ng-route in my web, some resources don't render properly, I need to reload the page to get it properly rendered, for example.
First I have this:
then when I reload, I get what I want:
What I cant understand is why other resources like google icons or buttons work correctly but the menu button on the nav bar and other resources like this one need to reaload the page in order to render properly.
I try to include the library using the hosted method and bower method.
Any idea what is going on?
i past in my code this function
angular.module('app', ['ngRoute']).
run(function($rootScope, xxxx, xxx){
$rootScope.$on('$viewContentLoaded', function(event, next) {
componentHandler.upgradeAllRegistered();
});
});
It worked perfect! Good luck..
Libraries like MDL work by waiting for the page to load using the DOMContentLoaded event, scanning the page for things like input elements and manipulating them with JavaScript so that they can inject the bits and pieces needed to work with their components. This works fine on static websites, but the DOMContentLoaded event only fires once, so when Angular performs a page transition, the DOM changes without MDL knowing about it.
Material Design Lite has a section in its FAQ about using MDL on dynamic websites:
Material Design Lite will automatically register and render all elements marked with MDL classes upon page load. However in the case where you are creating DOM elements dynamically you need to register new elements using the upgradeElement function. Here is how you can dynamically create the same raised button with ripples shown in the section above:
<div id="container"/>
<script>
var button = document.createElement('button');
var textNode = document.createTextNode('Click Me!');
button.appendChild(textNode);
button.className = 'mdl-button mdl-js-button mdl-js-ripple-effect';
componentHandler.upgradeElement(button);
document.getElementById('container').appendChild(button);
</script>
Of course, this probably isn't terribly easy to do in your case, since you'd have to manually find each new element and call upgradeElement on it.
Usually, instead of doing this sort of event-based DOM manipulation, Angular uses directives to initiate DOM changes. Consider using a library built to interoperate with Angular, instead, such as Angular Material.

Load a HTML page within another HTML page as a popup

I need to display or load a HTML page within another HTML page on a button click.I need this in a popup with the main html page as the background..pls can any tell me proper suggestions.
Take a look at the Facebox jQuery plugin. It does pretty much exactly what you're asking for. For example you can have a link like this to some remote page like so
text
then just call the facebox plugin when your content is loaded like so
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
});
and your content will render in a modal window. You can also take a look at Fancybox or ThickBox which provide very similar functionality.
try using windows.open() function.
for Example
var strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
var URL = "https://www.linkedin.com/cws/share?mini=true&url=" + location.href;
var win = window.open(URL, "_blank", strWindowFeatures);

Angular ngView with CKEditor disappearing text

cutting right to the chase here heh
Building an admin backend system with angular for a client. This site and backend are built with Node and Angular. I've got a post editor setup, so that when you click a link to edit a post, locationProvider and ngRoute go to work and swap out the partial with a new controller, and updates the url.
Here at this point, everything shows up perfectly.
It's when I click on Cancel (which is a standard link going back to the post list view) or submit (which works it's magic and then redirects to the same url as cancel) and this works.
It's when I click on the link to edit the same post again. The content that's supposed to be in the CKEditor is blank. However when using Chrome Dev Tools I can see that tw original input field has the content in it correctly, but the iframe has nothing in it at all but the CKEditor Chrome.
As for code,
In my controller it looks like this:
$scope.post = null;
$http.get('/api/post/'+$routeParams.id)
.success(function(data,status,headers){
$scope.post = data;
});
$(function() {
CKEDITOR.replace("content");
});
$scope.submit = function() {
// submission code here
};
Pretty basic here, just want to get the basics out of the way first.
Is the problem with how I'm loading CKEditor?
CKEDITOR.replace("content") would replace the html element with CKEditor instance. Assuming "content" is some div id or text area in your html.
To set the content you need to use
CKEDITOR.instances["content"].setData("Contents to be displayed in text area");

Angular ng view not rendering correctly in firefox - i just get "function () { return html; }"

I am in the middle of a reasonably size AngularJS app and our BDD's have started failing recently. It turns out that they are failing because after the first load of the site in firefox (i.e. reloading the page) causes the NG-View to render
function () { return html; }
the html for this is
<div data-ng-view="">
<span class="ng-scope">function () { return html; }</span>
</div>
I can reproduce this error in firefox easily by reloading the page but in Chrome/IE10 and IE10 in IE7 mode i can't reproduce it.
When debugging the app is 'booting' up normally - making a few service calls to get lookup data etc, registering services, directives and loading controllers.
When the page is in this state i can execute
angular.element($0).scope()
on the console and see the scope of
<html data-ng-controller="app.controller">
There are no errors in the console when the app is in this state, and if i set the debugger to pause on errors i get one error in jquery-min and nothing else.
Any ideas would be greatly appreciated. I can also post code samples to particular areas like routing if required.
*EDIT *
The issue was related to dynamically loading the controllers/html using some code from this google group
https://groups.google.com/forum/#!msg/angular/rs1dj097oHA/cPwPZfLvX4EJ
the fix to the code can be seen in the thread.
I haven't marked it as an answer because i feel there is a deeper issue in the way angular is treating 'routeDefinition.template' otherwise i would see either the html or the printing of the entire function ALL the time - not some seemingly random switching.
routeDefinition.template = function () {
return html;
};
cheers
kle

Resources