- Screen name: Gentle Media
Gentle Media's Profile
5 Posts
7 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 19-Apr-2014 11:38 AM
- Forum: Getting Started
Hi,
I have a blog post page with a next and previous post navigation with the following mark-up.- <header role="banner">
- <nav class="next-prev cf">
- <a class="ajax prev" href="<?php echo _LINK_PATH;?>a-desert-is-a-place-without-expectation">Prev – <span>title of previous blog post</span></a>
- <a class="ajax next" href="<?php echo _LINK_PATH;?>a-desert-is-a-place-without-expectation">Next – <span>title of next blog post</span></a>
- </nav>
- </header>
I have on the same page a lightbox gallery which also has keyboard navigation support for the lightbox images.
What I'm trying to do (and I'm pretty much there) is to disable/remove the post navigation from the DOM once user clicks on a lightbox thumbnail image to open viewer and when user closes the lightbox viewer it has to reinsert the post page nav back into the header.. Basically I have the following functions:- // store the post navigation in a variable
- var postNav = $('.next-prev');
- // remove the post naviagtion from the DOM when activating lightbox
- $( 'a[data-imagelightbox="a"]' ).on('click', function(e) {
postNav.detach();
}); - // insert it back in the header when closing lightbox by clicking on the document
$(document).mouseup(function(e) {
postNav.appendTo('[role="banner"]');
}); - // post nav keyboard arrows events
$(document).keydown(function(e) {
if(e.keyCode == 37) {
$('.prev').click();
};
if(e.keyCode == 39) {
$('.next').click();
};
// closing the lightbox can also be done with the 'escape' key, so we'll have to reinsert the post navigation to the header with this event too.
if(e.keyCode == 27) {
postNav.appendTo('[role="banner"]');
};
})
Like I said this all works well when using the keyboard, except that I can't use the mouse click on the post page navigation links. It probably has to do with the $(document).mouseup(), but I tried several things and the way I have it now comes the closest to the way I want it.
I tried instead of (document) also the ID of the lightbox overlay element (div), because this is besides the 'escape' key the only way to close the lightbox. Doing it like this I can use the mouse clciks on next and prev links, but it doesn't reinsert the nav .next-prev back into the header.
I also tried something with $(document).delegate(:not"('.next-prev > a')", mouseup, function() but no luck either or some tries with .not() to exclude .next-prev > a but also nothing that I could create that worked.
Obviously I have to use something else to achieve what I want, but I don't know what.
Does anyone has a clue?
Thanks!
Ralph- 17-Feb-2014 03:40 PM
- Forum: Using jQuery
I have setup a ajax website where I use the history API for a better user experience with a javascript fallback for browsers that don't support the API. I have to say that I've used files from a demo site from the maker of the fallback script, because my javascript/jQuery knowledge is 0.2.
I have a div where I load the AJAX content in which is hidden on page load. In the other div I have a isotope grid with items and clicking on a item will slide-in the AJAX div and loads at the same time the AJAX content.To slide in/out the AJAX div I just remove/add a class (slide-in) with jQuery on the grid div and animate margin-left with a CSS transition.This all works well if you click links and buttons in the HTML and I even managed to remove the 'slide-in' class if an AJAX page gets loaded or accessed directly in the browser.
But... I need also to remove the 'slide-in' class when user use the browser back/forward button and the url is http://aggenebbis.nl/ralph/home
I'm working on the website at the URL at the bottom and if you click on an item and use the browser back/forward button you'll see what I mean.You'll need the following credentials to gain access:
username: jquery
pass: forumThanks for your time!- 04-Jul-2013 12:24 PM
- Forum: Using jQuery Plugins
Hi guys,I'm using iCheck to style radio buttons and checkboxes with CSS. An awesome plugin!I have the following which works like a charm without iCheck:- $('input[name=radio-group-1]:radio').change(function() {
- if ($(this).val() == 'no') {
- $('.btn[href="#page-04"]').attr("href","#page-06");
- } else {
- $('.btn[href="#page-06"]').attr("href","#page-04");
- }
- });
To replicate the above while using iCheck I must use one or more of iCheck's callback functions. I've started with the callback function 'ifChecked' and gave my inputs an ID for easy targeting and I'm able to change with the following the href from #page-04 to #page-06, but it changes already on page load.- $(function(){
- if ($('#r2').on('ifChanged')) {
- $('.btn[href="#page-04"]').attr("href","#page-06");
- }
- });
And if i wrap it in the .change() function such as $('input[name=radio-group-1]:radio').change(function() - and add the 'else; statement as well, it doesn't do anythingIf someone can spot where I go wrong or perhaps do I need to use a iCheck method or another callback function... I'm lost.Thanks!
Ralph- 04-Jul-2013 07:42 AM
- Forum: Getting Started
Hi guys,I'm trying to change a href value of a button, but it's not working. I'm using jquery-1.8.0 and created a function like this:- $('input[name=radio-group-1]:radio').change(function() {
- if ($(this).val() == 'no') {
- $('.btn[href=http://www.google.com]').attr("href","http://www.yahoo.com");
- }
- });
HTML:- <label for="yes">Yes</label>
- <input type="radio" name="radio-group-1" value="yes" />
- <label for="no">No</label>
- <input type="radio" name="radio-group-1" value="no" />
- <a href="http://www.google.com" class="btn">next</a>
I've made a pen of it here:
http://codepen.io/gentleone/full/gKrABHope someone can point me in the right direction. Thanks in advance!- Hi all,Not new to the forum, but my first question.I'm working on a page where I use jQuery Isotope and jQuery Expander.On the 'Filter by' links I've attached a home made (Yes, I'm a jQuery newbie) function to the 'selected' item to move and replace content in a section with id 'locations'. The hidden content with the class 'location-info' follows the 'selected' item directly in the source order. What I did does do the job, but the kQuery expander script fails to work. I know what causes the issue, because I use .clone(). And I used .clone() cause it;s the only way I could get this move and replace to work. So this is what I have: and the part that I've added is from .next() unttil remove(). How can I do this better instead of clone the content. If I leave it out, it moves the hidden content to #locations,and my 'read more' link does work, but if i click on another link it does add the next '. location-info' but, doesn't remove the previous one.
- var $optionSets = $('#filter-sort .option-set'),
- $optionLinks = $optionSets.find('a');
- $optionLinks.click(function(){
- var $this = $(this);
- if ($this.hasClass('selected')) {
- return false;
- }
- var $optionSet = $this.parents('.option-set');
- $optionSet.find('.selected').removeClass('selected');
- $this.addClass('selected').next('.location-info').clone().fadeIn(500).appendTo($('#locations'));
- $('#locations').find('.location-info:last').prev('.location-info').remove();
- return false;
- });
- «Prev
- Next »
Moderate user : Gentle Media
© 2013 jQuery Foundation
Sponsored by and others.

