Search Results

Search found 668 results on 27 pages for 'addclass'.

Page 18/27 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Load links as unselected in jQuery

    - by shummel7845
    I have sets of links with id and name attributes, id for individual identifiers and names for groupings. In my jQuery, I have a click function that manipulates the CSS based on what a user clicks on. But I want to start the freshly loaded page with some of the links disabled (no href attribute) and with a style applied. I tried this, but it didn't work. $(function() // Alias for $(document).ready() { var $links = $('li a'); $links.(function(){ $('a[name="beam"]').filter(function() { $(this).addClass('unavailable'); $(this).removeAttr('href'); }); }); ...... Ideas? (Beam is one of the groupings by name).

    Read the article

  • animate each child jquery

    - by Martavis P.
    It's amazing how simple this should be but I can't get it to work. I'm looking to animate a set of divs one at a time. I am using animate.css for those familiar with it. I thought I may have found the answer here but jsFiddle is not working at the moment. Anywho, the code is $('.elements').each(function(i) { $(this).addClass('animated slideInLeft').delay(500); }); The problem is that when I debug and step through each element, the animation is happening for each element but when I let it run, it appears to all do it at once. What is needed to actually show the animation one at a time? Thanks EDIT: jsFiddle is back up and that link provided below did not help. The answer did not include looping through elements, but looping the animation itself. EDIT 2 Here is a Fiddle to play with if you guys need one.

    Read the article

  • Using jQuery, CKEditor, AJAX in ASP.NET MVC 2

    - by Ray Linder
    After banging my head for days on a “A potentially dangerous Request.Form value was detected" issue when post (ajax-ing) a form in ASP.NET MVC 2 on .NET 4.0 framework using jQuery and CKEditor, I found that when you use the following: Code Snippet $.ajax({     url: '/TheArea/Root/Add',     type: 'POST',     data: $("#form0Add").serialize(),     dataType: 'json',     //contentType: 'application/json; charset=utf-8',     beforeSend: function ()     {         pageNotify("NotifyMsgContentDiv", "MsgDefaultDiv", '<img src="/Content/images/content/icons/busy.gif" /> Adding post, please wait...', 300, "", true);         $("#btnAddSubmit").val("Please wait...").addClass("button-disabled").attr("disabled", "disabled");     },     success: function (data)     {         $("#btnAddSubmit").val("Add New Post").removeClass("button-disabled").removeAttr('disabled');         redirectToUrl("/Exhibitions");     },     error: function ()     {         pageNotify("NotifyMsgContentDiv", "MsgErrorDiv", '<img src="/Content/images/content/icons/cross.png" /> Could not add post. Please try again or contact your web administrator.', 6000, "normal");         $("#btnAddSubmit").val("Add New Post").removeClass("button-disabled").removeAttr('disabled');     } }); Notice the following: Code Snippet data: $("#form0Add").serialize(), You may run into the “A potentially dangerous Request.Form value was detected" issue with this. One of the requirements was NOT to disable ValidateRequest (ValidateRequest=”false”). For this project (and any other project) I felt it wasn’t necessary to disable ValidateRequest. Note: I’ve search for alternatives for the posting issue and everyone and their mothers continually suggested to disable ValidateRequest. That bothers me – a LOT. So, disabling ValidateRequest is totally out of the question (and always will be).  So I thought to modify how the “data: “ gets serialized. the ajax data fix was simple, add a .html(). YES!!! IT WORKS!!! No more “potentially dangerous” issue, ajax form posts (and does it beautifully)! So if you’re using jQuery to $.ajax() a form with CKEditor, remember to do: Code Snippet data: $("#form0Add").serialize().html(), or bad things will happen. Also, don’t forget to set Code Snippet config.htmlEncodeOutput = true; for the CKEditor config.js file (or equivalent). Example: Code Snippet CKEDITOR.editorConfig = function( config ) {     // Define changes to default configuration here. For example:     // config.language = 'fr';     config.uiColor = '#ccddff';     config.width = 640;     config.ignoreEmptyParagraph = true;     config.resize_enabled = false;     config.skin = 'kama';     config.enterMode = CKEDITOR.ENTER_BR;       config.toolbar = 'MyToolbar';     config.toolbar_MyToolbar =     [         ['Bold', 'Italic', 'Underline'],         ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', 'Font', 'FontSize', 'TextColor', 'BGColor'],         ['BulletedList', 'NumberedList', '-', 'Outdent', 'Indent'],         '/',         ['Scayt', '-', 'Cut', 'Copy', 'Paste', 'Find'],         ['Undo', 'Redo'],         ['Link', 'Unlink', 'Anchor', 'Image', 'Flash', 'HorizontalRule'],         ['Table'],         ['Preview', 'Source']     ];     config.htmlEncodeOutput = true; }; Happy coding!!! Tags: jQuery ASP.NET MVC 2 ASP.NET 4.0 AJAX

    Read the article

  • Is my JavaScript/jQuery methodology good? [migrated]

    - by absentx
    I am seeking critique on what has become my normal methodology of writing JavaScript code. I have become heavily reliant on the jQuery library, but I think this has helped me learn the native language better also. Anyway, please critique the following style of JavaScript coding... Buried are a lot of questions of scope; if you could point out the strengths and weaknesses of this style I would appreciate it. var critique ={ start: function(){ globalness = 'GLOBAL-GLOBAL'; //Available to all critique's methods var notglobalness = 'LOCAL-LOCAL'; // Only available to critiques start method //Am I using the "method" teminology properly here?? $('#stuff').on('click','a.closer-target',function(){ $target = $(this); if($target.hasClass('active')){ $target.removeClass('active'); } else{ $target.addClass('active'); critique.madness($target); } }) console.log(notglobalness+': at least I am useful at home'); console.log('note here that: '+notglobalness+' is no longer available after this point, lets continue on:'); critique.madness(notglobalness); }, madness: function($e){ //Do a bunch of awesomeness with $e, //but continue to keep it seperate because you think its best to keep things isolated. //Send to the next function when complete here console.log('Here is globalness, which is still available from the start method of critique!! ' + globalness); console.log('Let us see if the globalness carries on to a new var object!!'); console.log('The locally isolated variable of NOTGLOBALNESS is available here, because it was passed to this method. Let us show it:'+$e); carryOn.start(); } } //end critique var carryOn={ start: function(){ console.log('any chance critique.globalness will work here??? lets see: ' +globalness); console.log('it absolutely does'); } } $(document).ready(critique.start); (I always struggle with which of the Stack Exchange sites is best to post "questions of theory" like this, but I think Programmers is the best, if not, as usual a mod will move it, etc...)

    Read the article

  • JQuery Validation [migrated]

    - by user41354
    Im trying to get my form to validate...so basically its working, but a little bit too well, I have two text boxes, one is a start date, the other an end date in the format of mm/dd/yyyy if the start date is greater than the end date...there is an error if the end date is less than the start date...there is an error if the start date is less than today's date...there is an error The only thing is when I correct the error, the error warning is still there...here is my code: dates.change(function () { var testDate = $(this).val(); var otherDate = dates.not(this).val(); var now = new Date(); now.setHours(0, 0, 0, 0); // Pass Dates if (testDate != '' && new Date(testDate) < now) { addError($(this)); $('.flightDateError').text('* Dates cannot be earlier than today.'); isValid = false; return; } // Required Text if ($(this).hasClass("FromCal") && testDate == '') { addError($(this)); $('.flightDateError').text('* Required'); isValid = false; return; } // Validate Date if (!isValidDate(testDate)) { // $(this).addClass('validation_error_input'); addError($(this)); $('.flightDateError').text('* Invalid Date'); isValid = false; return; } else { // $(this).removeClass('validation_error_input'); removeError($(this)); if (!dates.not(this).hasClass('validation_error_input')) $('.flightDateError').text(' '); } // Validate Date Ranges if ($(this).val() != '' && dates.not(this).val != '') { if ($(this).hasClass("FromCal")) { if (new Date(testDate) > new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* Start date must be earlier than end date.'); isValid = false; return; } } else{ if (new Date(testDate) < new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* End date must be later than start date.'); return; } } } }); The main Issue is this part, I believe // Validate Date Ranges if ($(this).val() != '' && dates.not(this).val != '') { if ($(this).hasClass("FromCal")) { if (new Date(testDate) > new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* Start date must be earlier than end date.'); isValid = false; return; } } else{ if (new Date(testDate) < new Date(otherDate)) { addError($(this)); $('.flightDateError').text('* End date must be later than start date.'); return; } } } testDate is the start date otherDate is the end date Thanks in advanced, J

    Read the article

  • is this correct use of jquery's document.ready?

    - by Haroldo
    The below file contains all the javascript for a page. Performance is the highest priority. Is this the most efficient way? Do all click/hover events need to to be inside the doc.ready? //DOCUMENT.READY EVENTS //--------------------------------------------------------------------------- $(function(){ // mark events as not loaded $('.event').data({ t1_loaded: false, t2_loaded: false, t3_loaded: false, art_req: false }); //mark no events have been clicked $('#wrap_right').data('first_click_made', false); // cal-block event click $('#cal_blocks div.event, #main_search div.event').live('click', function(){ var id = $(this).attr('id').split('e')[1]; event_click(id); }); // jq history $.historyInit(function(hash){ if(hash) { event_click(hash); } }); // search $('#search_input').typeWatch ({ callback: function(){ var q = $('#search_input').attr('value'); search(q); }, wait : 350, highlight : false, captureLength : 2 }); $('#search_input, #main_search div.close').live('click',function(){ $(this).attr("value",""); reset_srch_res(); }); $('#main_search').easydrag(); $('a.dialog').colorbox(); //TAB CLICK -> AJAX LOAD TAB $('#wrap_right .rs_tabs li').live('click', function(){ $this = $(this); var id = $('#wrap_right').data('curr_event'); var tab = parseInt($this.attr('rel')); //hide other tabs $('#rs_'+id+' .tab_body').hide(); //mark current(clicked) tab $('#rs_'+id+' .rs_tabs li').removeClass('curr_tab'); $this.addClass('curr_tab'); //is the tab already loaded and hidden? var loaded = $('#e'+id).data('t'+tab+'_loaded'); //console.log('id: '+id+', tab: '+tab+', loaded: '+loaded); if(loaded === true) { $('#rs_'+id+' .tab'+tab).show(); if (tab == 2) { art_requested(id); } } else { //ajax load in the tab $('#rs_'+id+' .tab'+tab).load('index_files/tab'+tab+'.php?id='+id, function(){ //after load callback if (tab == 1) { $('#rs_' + id + ' .frame').delay(600).fadeIn(600) }; if (tab == 2) { art_requested(id); } }); //mark tab as loaded $('#e'+id).data('t'+tab+'_loaded', true); //fade in current tab $('#rs_'+id+' .tab'+tab).show(); } }) }); // LOAD RS FUNCTIONS //--------------------------------------------------------------------------- function event_click(id){ window.location.hash = id; //mark current event $('#wrap_right').data('curr_event', id); //hide any other events if($('#wrap_right').data('first_click_made') === true) { $('#wrap_right .event_rs').hide(); } //frame loaded before? var loaded = $('#e'+id).data('t1_loaded'); if(loaded === true) { $('#rs_'+id).show(); } else { create_frame(id); } //open/load the first tab $('#rs_'+id+' .t1').click(); $('#wrap_right').data('first_click_made', true); $('#cal_blocks').scrollTo('#e'+id, 1000, {offset: {top:-220, left:0}}); } function create_frame(id){ var art = ents[id].art; var ven = ents[id].ven; var type = ents[id].gig_club; //select colours for tabs if(type == 1){ var label = 'gig';} else if(type == 2){ var label = 'club';} else if(type == 0){ var label = 'other';} //create rs container for this event var frame = '<div id="rs_'+id+'" class="event_rs">'; frame += '<div class="title_strip"></div>'; frame += '<div class="rs_tabs"><ul class="'+label+'"><li class="t1 nav_tab1 curr_tab hand" rel="1"></li>'; if(art == 1){frame += '<li class="t2 nav_tab2 hand" rel="2"></li>';} if(ven == 1){frame += '<li class="t3 nav_tab2 hand" rel="3"></li>';} frame += '</ul></div>'; frame += '<div id="rs_content"><div class="tab_body tab1" ></div>'; if(art == 1){frame += '<div class="tab_body tab2"></div>';} if(ven == 1){frame += '<div class="tab_body tab3"></div>';} frame += '</div>'; frame += '</div>'; $('#wrap_right').append(frame); //mark current event in cal-blocks $('#cal_blocks .event_sel').removeClass('event_sel'); $('#e'+id).addClass('event_sel'); if($('#wrap_right').data('first_click_made') === false) { $('#wrap_right').delay(500).slideDown(); $('#rs_'+id+' .rs_tabs').delay(800).fadeIn(); } }; // FUNCTIONS //--------------------------------------------------------------------------- //check to see if an artist has been requested function art_requested(id){ var art_req = $('#e'+id).data('art_req'); if(art_req !== false) { //alert(art_req); $('#art_'+art_req).click(); } } //scroll artist panes smoothly (scroll bars cause glitches otherwise) function before (){ if(!IE){$('#art_scrollable .bio_etc').css('overflow','-moz-scrollbars-none');} } function after (){ if(!IE){$('#art_scrollable .bio_etc').css('overflow','auto');} } function prep_media_carousel(){ //youtube and soundcloud player $("#rs_content .yt_scrollable a.yt, #rs_content .yt_scrollable a.sc").colorbox({ overlayClose : false, opacity : 0 }); $("#colorbox").easydrag(true); $('#cboxOverlay').remove(); } function make_carousel_scrollable(unique_id){ $('#scroll_'+unique_id).scrollable({ size:1, clickable:false, nextPage:'#r_'+unique_id, prevPage:'#l_'+unique_id }); } function check_l_r_arrows(total, counter, art_id){ //left arrow if(counter > 0) { $('#l_'+art_id).show(); $('#l_'+art_id+'_inactive').hide(); } else { $('#l_'+art_id).hide(); $('#l_'+art_id+'_inactive').show(); } //right arrow if(counter < total-3) { $('#r_'+art_id).show(); $('#r_'+art_id+'_inactive').hide(); } else { $('#r_'+art_id).hide(); $('#r_'+art_id+'_inactive').show(); } } function reset_srch_res(){ $('#main_search').fadeOut(400).children().remove(); } function search(q){ $.ajax({ type: 'GET', url: 'index_files/srch/search.php?q='+q, success: function(e) { $('#main_search').html(e).show(); } }); }

    Read the article

  • vertical accordion from horizontal

    - by Sify Juhy
    //# jQuery - Horizontal Accordion //# Version 2.00.00 Alpha 1 //# //# portalZINE(R) - New Media Network //# http://www.portalzine.de //# //# Alexander Graef //# [email protected] //# //# Copyright 2007-2009 (function($) { $.hrzAccordion = { setOnEvent: function(i, container, finalWidth, settings){ $("#"+container+"Handle"+i).bind(settings.eventTrigger,function() { var status = $('[rel='+container+'ContainerSelected]').data('status'); if(status ==1 && settings.eventWaitForAnim === true){ return false; } if( $("#"+container+"Handle"+i).attr("rel") != container+"HandleSelected"){ settings.eventAction; $('[id*='+container+'Handle]').attr("rel",""); $('[id*='+container+'Handle]').attr("class",settings.handleClass); $("#"+container+"Handle"+i).addClass(settings.handleClassSelected); $("."+settings.contentWrapper).css({width: finalWidth+"px" }); switch(settings.closeOpenAnimation) { case 1: if($('[rel='+container+'ContainerSelected]').get(0) ){ $('[rel='+container+'ContainerSelected]').data('status',1); //current_width = $('[rel='+container+'ContainerSelected]').width(); $('[rel='+container+'ContainerSelected]').animate({width: "0px",opacity:"0"}, { queue:true, duration:settings.closeSpeed ,easing:settings.closeEaseAction,complete: function(){ $('[rel='+container+'ContainerSelected]').data('status',0); } ,step: function(now){ width = $(this).width(); //new_width = finalWidth- (finalWidth * (width/current_width)); new_width = finalWidth - width; $('#'+container+'Content'+i).width(Math.ceil(new_width)).css("opacity","1"); }}); }else{ $('[rel='+container+'ContainerSelected]').data('status',1); $('#'+container+'Content'+i).animate({width: finalWidth,opacity:"1"}, { queue:false, duration:settings.closeSpeed ,easing:settings.closeEaseAction,complete: function(){ $('[rel='+container+'ContainerSelected]').data('status',0); }}); } break; case 2: $('[id*='+container+'Content]').css({width: "0px"}); $('#'+container+'Content'+i).animate({width: finalWidth+"px",opacity:"1"}, { queue:false, duration:settings.openSpeed ,easing:settings.openEaseAction, complete: settings.completeAction }); break; } $('[id*='+container+'Content]').attr("rel",""); $("#"+container+"Handle"+i).attr("rel",container+"HandleSelected"); $("#"+container+"Content"+i).attr("rel",container+"ContainerSelected"); } }); } }; $.fn.extend({ hrzAccordionLoop: function(options) { return this.each(function(a){ var container = $(this).attr("id") || $(this).attr("class"); var elementCount = $('#'+container+' > li, .'+container+' > li').size(); var settings = $(this).data('settings'); variable_holder="interval"+container ; var i =0; var loopStatus = "start"; variable_holder = window.setInterval(function(){ $("#"+container+"Handle"+i).trigger(settings.eventTrigger); if(loopStatus =="start"){ i = i + 1; }else{ i = i-1; } if(i==elementCount && loopStatus == "start"){ loopStatus = "end"; i=elementCount-1; } if(i==0 && loopStatus == "end"){ loopStatus = "start"; i=0; } },settings.cycleInterval); }); }, hrzAccordion: function(options) { this.settings = { eventTrigger : "click", containerClass : "container", listItemClass : "listItem", contentContainerClass : "contentContainer", contentWrapper : "contentWrapper", contentInnerWrapper : "contentInnerWrapper", handleClass : "handle", handleClassOver : "handleOver", handleClassSelected : "handleSelected", handlePosition : "right", handlePositionArray : "", // left,left,right,right,right closeEaseAction : "swing", closeSpeed : 500, openEaseAction : "swing", openSpeed : 500, openOnLoad : 2, hashPrefix : "tab", eventAction : function(){ //add your own extra clickAction function here }, completeAction : function(){ //add your own onComplete function here }, closeOpenAnimation : 1,// 1 - open and close at the same time / 2- close all and than open next cycle : false, // not integrated yet, will allow to cycle through tabs by interval cycleInterval : 10000, fixedWidth : "", eventWaitForAnim : true }; if(options){ $.extend(this.settings, options); } var settings = this.settings; return this.each(function(a){ var container = $(this).attr("id") || $(this).attr("class"); $(this).data('settings', settings); $(this).wrap("<div class='"+settings.containerClass+"'></div>"); var elementCount = $('#'+container+' > li, .'+container+' > li').size(); var containerWidth = $("."+settings.containerClass).width(); var handleWidth = $("."+settings.handleClass).css("width"); handleWidth = handleWidth.replace(/px/,""); var finalWidth; var handle; if(settings.fixedWidth){ finalWidth = settings.fixedWidth; }else{ finalWidth = containerWidth-(elementCount*handleWidth)-handleWidth; } $('#'+container+' > li, .'+container+' > li').each(function(i) { $(this).attr('id', container+"ListItem"+i); $(this).attr('class',settings.listItemClass); $(this).html("<div class='"+settings.contentContainerClass+"' id='"+container+"Content"+i+"'>" +"<div class=\""+settings.contentWrapper+"\">" +"<div class=\""+settings.contentInnerWrapper+"\">" +$(this).html() +"</div></div></div>"); if($("div",this).hasClass(settings.handleClass)){ var html = $("div."+settings.handleClass,this).attr("id",""+container+"Handle"+i+"").html(); $("div."+settings.handleClass,this).remove(); handle = "<div class=\""+settings.handleClass+"\" id='"+container+"Handle"+i+"'>"+html+"</div>"; }else{ handle = "<div class=\""+settings.handleClass+"\" id='"+container+"Handle"+i+"'></div>"; } if(settings.handlePositionArray){ splitthis = settings.handlePositionArray.split(","); settings.handlePosition = splitthis[i]; } switch(settings.handlePosition ){ case "left": $(this).prepend( handle ); break; case "right": $(this).append( handle ); break; case "top": $("."+container+"Top").append( handle ); break; case "bottom": $("."+container+"Bottom").append( handle ); break; } $("#"+container+"Handle"+i).bind("mouseover", function(){ $("#"+container+"Handle"+i).addClass(settings.handleClassOver); }); $("#"+container+"Handle"+i).bind("mouseout", function(){ if( $("#"+container+"Handle"+i).attr("rel") != "selected"){ $("#"+container+"Handle"+i).removeClass(settings.handleClassOver); } }); $.hrzAccordion.setOnEvent(i, container, finalWidth, settings); if(i == elementCount-1){ $('#'+container+",."+container).show(); } if(settings.openOnLoad !== false && i == elementCount-1){ var location_hash = location.hash; location_hash = location_hash.replace("#", ""); if(location_hash.search(settings.hashPrefix) != '-1' ){ var tab = 1; location_hash = location_hash.replace(settings.hashPrefix, ""); } if(location_hash && tab ==1){ $("#"+container+"Handle"+(location_hash)).attr("rel",container+"HandleSelected"); $("#"+container+"Content"+(location_hash)).attr("rel",container+"ContainerSelected"); $("#"+container+"Handle"+(location_hash-1)).trigger(settings.eventTrigger); }else{ $("#"+container+"Handle"+(settings.openOnLoad)).attr("rel",container+"HandleSelected"); $("#"+container+"Content"+(settings.openOnLoad)).attr("rel",container+"ContainerSelected"); $("#"+container+"Handle"+(settings.openOnLoad-1)).trigger(settings.eventTrigger); } } }); if(settings.cycle === true){ $(this).hrzAccordionLoop(); } }); } }); })(jQuery); **Given is the code used for the accordion...please check out this Accordion Link. in the link there are four examples of accordions. i want the last accordion i.e example 4 to be vertical ...kindly help me.

    Read the article

  • How to autostart this slide

    - by lchales
    Hello there: first of all i have no idea on coding or anything related, simple question: is there any simple way to tell this code to autostart the slide? at the current moment the images change on click. currently the index page only have one image, what i want is to add a few but without the need to click to see the next one here is the code from my index: <script type="text/javascript"> //<![CDATA[ /* the images preload plugin */ (function($) { $.fn.preload = function(options) { var opts = $.extend({}, $.fn.preload.defaults, options), o = $.meta ? $.extend({}, opts, this.data()) : opts; var c = this.length, l = 0; return this.each(function() { var $i = $(this); $('<img/>').load(function(i){ ++l; if(l == c) o.onComplete(); }).attr('src',$i.attr('src')); }); }; $.fn.preload.defaults = { onComplete : function(){return false;} }; })(jQuery); //]]> </script><script type="text/javascript"> //<![CDATA[ $(function() { var $tf_bg = $('#tf_bg'), $tf_bg_images = $tf_bg.find('img'), $tf_bg_img = $tf_bg_images.eq(0), $tf_thumbs = $('#tf_thumbs'), total = $tf_bg_images.length, current = 0, $tf_content_wrapper = $('#tf_content_wrapper'), $tf_next = $('#tf_next'), $tf_prev = $('#tf_prev'), $tf_loading = $('#tf_loading'); //preload the images $tf_bg_images.preload({ onComplete : function(){ $tf_loading.hide(); init(); } }); //shows the first image and initializes events function init(){ //get dimentions for the image, based on the windows size var dim = getImageDim($tf_bg_img); //set the returned values and show the image $tf_bg_img.css({ width : dim.width, height : dim.height, left : dim.left, top : dim.top }).fadeIn(); //resizing the window resizes the $tf_bg_img $(window).bind('resize',function(){ var dim = getImageDim($tf_bg_img); $tf_bg_img.css({ width : dim.width, height : dim.height, left : dim.left, top : dim.top }); }); //expand and fit the image to the screen $('#tf_zoom').live('click', function(){ if($tf_bg_img.is(':animated')) return false; var $this = $(this); if($this.hasClass('tf_zoom')){ resize($tf_bg_img); $this.addClass('tf_fullscreen') .removeClass('tf_zoom'); } else{ var dim = getImageDim($tf_bg_img); $tf_bg_img.animate({ width : dim.width, height : dim.height, top : dim.top, left : dim.left },350); $this.addClass('tf_zoom') .removeClass('tf_fullscreen'); } } ); //click the arrow down, scrolls down $tf_next.bind('click',function(){ if($tf_bg_img.is(':animated')) return false; scroll('tb'); }); //click the arrow up, scrolls up $tf_prev.bind('click',function(){ if($tf_bg_img.is(':animated')) return false; scroll('bt'); }); //mousewheel events - down / up button trigger the scroll down / up $(document).mousewheel(function(e, delta) { if($tf_bg_img.is(':animated')) return false; if(delta > 0) scroll('bt'); else scroll('tb'); return false; }); //key events - down / up button trigger the scroll down / up $(document).keydown(function(e){ if($tf_bg_img.is(':animated')) return false; switch(e.which){ case 38: scroll('bt'); break; case 40: scroll('tb'); break; } }); } //show next / prev image function scroll(dir){ //if dir is "tb" (top -> bottom) increment current, //else if "bt" decrement it current = (dir == 'tb')?current + 1:current - 1; //we want a circular slideshow, //so we need to check the limits of current if(current == total) current = 0; else if(current < 0) current = total - 1; //flip the thumb $tf_thumbs.flip({ direction : dir, speed : 400, onBefore : function(){ //the new thumb is set here var content = '<span id="tf_zoom" class="tf_zoom"><\/span>'; content +='<img src="' + $tf_bg_images.eq(current).attr('longdesc') + '" alt="Thumb' + (current+1) + '"/>'; $tf_thumbs.html(content); } }); //we get the next image var $tf_bg_img_next = $tf_bg_images.eq(current), //its dimentions dim = getImageDim($tf_bg_img_next), //the top should be one that makes the image out of the viewport //the image should be positioned up or down depending on the direction top = (dir == 'tb')?$(window).height() + 'px':-parseFloat(dim.height,10) + 'px'; //set the returned values and show the next image $tf_bg_img_next.css({ width : dim.width, height : dim.height, left : dim.left, top : top }).show(); //now slide it to the viewport $tf_bg_img_next.stop().animate({ top : dim.top },700); //we want the old image to slide in the same direction, out of the viewport var slideTo = (dir == 'tb')?-$tf_bg_img.height() + 'px':$(window).height() + 'px'; $tf_bg_img.stop().animate({ top : slideTo },700,function(){ //hide it $(this).hide(); //the $tf_bg_img is now the shown image $tf_bg_img = $tf_bg_img_next; //show the description for the new image $tf_content_wrapper.children() .eq(current) .show(); }); //hide the current description $tf_content_wrapper.children(':visible') .hide() } //animate the image to fit in the viewport function resize($img){ var w_w = $(window).width(), w_h = $(window).height(), i_w = $img.width(), i_h = $img.height(), r_i = i_h / i_w, new_w,new_h; if(i_w > i_h){ new_w = w_w; new_h = w_w * r_i; if(new_h > w_h){ new_h = w_h; new_w = w_h / r_i; } } else{ new_h = w_w * r_i; new_w = w_w; } $img.animate({ width : new_w + 'px', height : new_h + 'px', top : '0px', left : '0px' },350); } //get dimentions of the image, //in order to make it full size and centered function getImageDim($img){ var w_w = $(window).width(), w_h = $(window).height(), r_w = w_h / w_w, i_w = $img.width(), i_h = $img.height(), r_i = i_h / i_w, new_w,new_h, new_left,new_top; if(r_w > r_i){ new_h = w_h; new_w = w_h / r_i; } else{ new_h = w_w * r_i; new_w = w_w; } return { width : new_w + 'px', height : new_h + 'px', left : (w_w - new_w) / 2 + 'px', top : (w_h - new_h) / 2 + 'px' }; } }); //]]> </script>

    Read the article

  • jQuery for dynamic Add/Remove row function, it's clone() objcet cannot modify element name

    - by wcy0942
    I'm try jQuery for dynamic Add/Remove row function, but I meet some question in IE8 , it's clone() objcet cannot modify element name and cannot use javascript form (prhIndexed[i].prhSrc).functionKey, but in FF it works very well, source code as attachment, please give me a favor to solve the problem. <html> $(document).ready(function() { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Define some variables - edit to suit your needs //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // table id var _table = jQuery("#prh"); // modify here // tbody tbody var _tableBody = jQuery("tbody",_table); // buttons var _addRowBtn = jQuery("#controls #addRow"); var _insertRowBtn= jQuery("#controls #insertRow"); var _removeRowBtn= jQuery("#controls #removeRow"); //check box all var _cbAll= jQuery(".checkBoxAll", _table ); // add how many rows var _addRowsNumber= jQuery("#controls #add_rows_number"); var _hiddenControls = jQuery("#controls .hiddenControls"); var blankRowID = "blankRow"; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //click the add row button //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _addRowBtn.click(function(){ // when input not isNaN do add row if (! isNaN(_addRowsNumber.attr('value')) ){ for (var i = 0 ; i < _addRowsNumber.attr('value') ;i++){ var newRow = jQuery("#"+blankRowID).clone(true).appendTo(_tableBody) .attr("style", "display: ''") .addClass("rowData") .removeAttr("id"); } refreshTable(_table); } return false; //kill the browser default action }); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //checkbox select all //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _cbAll.click(function(){ var checked_status = this.checked; var prefixName = _cbAll.attr('name'); // find name prefix match check box (group of table) jQuery("input[name^='"+prefixName+"']").each(function() { this.checked = checked_status; }); }); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Click the remove all button //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _removeRowBtn.click(function(){ var prefixName = _cbAll.attr('name'); // find name prefix match check box (group of table) jQuery("input[name^='"+prefixName+"']").not(_cbAll).each(function() { if (this.checked){ // remove tr row , ckbox name the same with rowid jQuery("#"+this.name).remove(); } }); refreshTable(_table); return false; }); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Click the insert row button //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _insertRowBtn.click(function(){ var prefixName = _cbAll.attr('name'); jQuery("input[name^='"+prefixName+"']").each(function(){ var currentRow = this.name;// ckbox name the same with rowid if (this.checked == true){ newRow = jQuery("#"+blankRowID).clone(true).insertAfter(jQuery("#"+currentRow)) .attr("style", "display: ''") .addClass("rowData") .removeAttr("id"); } }); refreshTable(_table); return false; }); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Function to refresh new row //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function refreshTable(_table){ var tableId = _table.attr('id'); var count =1; // ignore hidden column // update tr rowid jQuery ( "#"+tableId ).find(".rowData").each(function(){ jQuery(this).attr('id', tableId + "_" + count ); count ++; }); count =0; jQuery ( "#"+tableId ).find("input[type='checkbox'][name^='"+tableId+"']").not(".checkBoxAll").each(function(){ // update check box id and name (not check all) jQuery(this).attr('id', tableId + "_ckbox" + count ); jQuery(this).attr('name', tableId + "_" + count ); count ++; }); // write customize code here customerRow(_table); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Function to customer new row : modify here //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function customerRow(_table){ var form = document.myform; var pageColumns = ["prhSeq", "prhChannelproperty", "prhSrc"]; //modify here var tableId = _table.attr('id'); var count =1; // ignore hidden column // update tr rowid jQuery ( "#"+tableId ).find(".rowData").each(function(){ for(var i = 0; i < pageColumns.length; i++){ jQuery ( this ).find("input[name$='"+pageColumns[i]+"']").each(function(){ jQuery(this).attr('name', 'prhIndexed['+count+'].'+pageColumns[i] ); // update prhSeq Value if (pageColumns[i] == "prhSeq") { jQuery(this).attr('value', count ); } if (pageColumns[i] == "prhSrc") { // clear default onfocus //jQuery(this).attr("onfocus", ""); jQuery(this).focus(function() { // doSomething }); } }); jQuery ( this ).find("select[name$='"+pageColumns[i]+"']").each(function(){ jQuery(this).attr('name', 'prhIndexed['+count+'].'+pageColumns[i] ); }); }// end of for count ++; }); jQuery ( "#"+tableId ).find(".rowData").each(function(){ // only for debug alert ( jQuery(this).html() ) }); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }); <div id="controls"> <table width="350px" border="0"> <tr><td> <input id="addRow" type="button" name="addRows" value="Add Row" /> <input id="add_rows_number" type="text" name="add_rows_number" value="1" style="width:20px;" maxlength="2" /> <input id="insertRow" type="button" name="insert" value="Insert Row" /> <input id="removeRow" type="button" name="deleteRows" value="Delete Row" /> </td></tr> </table></div> <table id="prh" width="350px" border="1"> <thead> <tr class="listheader"> <td nowrap width="21"><input type="checkbox" name="prh_" class="checkBoxAll"/></td> <td nowrap width="32">Sequence</td> <td nowrap width="153" align="center">Channel</td> <td nowrap width="200">Source</td> </tr> </thead> <tbody> <!-- dummy row --> <tr id='blankRow' style="display:none" > <td><input type="checkbox" id='prh_ckbox0' name='prh_0' value=""/></td> <td align="right"><input type="text" name="prhIndexed[0].prhSeq" maxlength="10" value="" onkeydown="" onblur="" onfocus="" readonly="readonly" style="width:30px;background-color:transparent;border:0;line-height:13pt;color: #993300;background-color:transparent;border:0;line-height:13pt;color: #993300;"></td> <td><select name="prhIndexed[0].prhChannelproperty"><option value=""></option> <option value="A01">A01</option> <option value="A02">A02</option> <option value="A03">A03</option> <option value="A04">A04</option> </select></td> <td><input type="text" name="prhIndexed[0].prhSrc" maxlength="6" value="new" style="width:80px;background-color:#FFFFD7;"> <div id='displayPrhSrcName0'></div> </td> </tr> <!-- row data --> <tr id='prh_1' class="rowData"> <td><input type="checkbox" id='prh_ckbox1' name='prh_1' value=""/></td> <td align="right"><input type="text" name="prhIndexed[1].prhSeq" maxlength="10" value="1" onkeydown="" onblur="" onfocus="" readonly="readonly" style="width:30px;background-color:transparent;border:0;line-height:13pt;color: #993300;background-color:transparent;border:0;line-height:13pt;color: #993300;"></td> <td><select name="prhIndexed[1].prhChannelproperty"><option value=""></option> <option value="A01">A01</option> <option value="A02">A02</option> <option value="A03">A03</option> <option value="A04">A04</option> </select></td> <td><input type="text" name="prhIndexed[1].prhSrc" maxlength="6" value="new" style="width:80px;background-color:#FFFFD7;"> <div id='displayPrhSrcName0'></div> </td> </tr> <tr id='prh_2' class="rowData"> <td><input type="checkbox" id='prh_ckbox2' name='prh_2' value=""/></td> <td align="right"><input type="text" name="prhIndexed[2].prhSeq" maxlength="10" value="2" onkeydown="" onblur="" onfocus="" readonly="readonly" style="width:30px;background-color:transparent;border:0;line-height:13pt;color: #993300;background-color:transparent;border:0;line-height:13pt;color: #993300;"></td> <td><select name="prhIndexed[2].prhChannelproperty"><option value=""></option> <option value="A01">A01</option> <option value="A02">A02</option> <option value="A03">A03</option> <option value="A04">A04</option> </select></td> <td><input type="text" name="prhIndexed[2].prhSrc" maxlength="6" value="new" style="width:80px;background-color:#FFFFD7;"> <div id='displayPrhSrcName0'></div> </td> </tr> </tbody> </table>

    Read the article

  • jquery load and tinymce gives me a "g.win.document is null" on subsequent loads

    - by Patrice Peyre
    So... very excited as first post on stackoverflow I have this page, clicking a button will call editIEPProgram(). editIEPProgram counts how many specific divs exists, adds another div, loads it with html from '/content/mentoring/iep_program.php' and then calls $("textarea.tinymce").tinymce to add a rich text editor to the newly added text boxes. It finally adds a tab which handles the new stuff and bob is your uncle. It ALMOST works. Clicking the button the first adds everything and everything woks, on the second and subsequent click, everything is added but the tinymce fails to initiate (I guess) and gives me "g.win.document is null". I have been on it for some time now and losing all my sanity. please, help.me. function editIEPProgram(){ var index = $("div[id^=iep_program]").size(); var target_div = "iep_program_"+index; $("#program_container") .append( $("<div></div>") .attr("id", target_div) .addClass("no_overflow_control") ); $("#"+target_div).load ( "/content/mentoring/iep_program.php", {index:index}, function() { $("textarea.tinymce").tinymce({ script_url: "/scripts/tiny_mce.js",height:"60", theme:"advanced",skin:"o2k7",skin_variant : "silver", plugins : "spellchecker,advlist,preview,pagebreak,style,layer,save,advhr,advimage,advlink,searchreplace,paste,noneditable,visualchars,nonbreaking,xhtmlxtras", theme_advanced_buttons1 : "spellchecker,|,bold,italic,underline,strikethrough,|,formatselect,|,forecolor,backcolor,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,image,cleanup,preview", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", content_css : "/css/main.css" }); }); $("#tab_container") .tabs("add", "#"+target_div,"New program") .tabs("select", $("#tab_container").tabs("length")-1); }

    Read the article

  • Can't create more than one overlay in Seadragon

    - by XGreen
    Hi everyone, I am trying to add overlays to a seadragon map I am making but for some reason that I can not figure our seadragon ignores all my overlays except the first one. Any help with this is much appreciated. var viewer = null; function init() { Seadragon.Config.autoHideControls = false; viewer = new Seadragon.Viewer("container"); viewer.addEventListener("open", addOverlays); viewer.addControl(makeControl(), Seadragon.ControlAnchor.TOP_RIGHT); $(viewer.getNavControl()).parent().parent().css({ 'top': 10, 'right': 10 }); viewer.openDzi("_assets/Mapdata/dzc_output.xml"); } function makeControl() { var control = document.createElement("a"); var controlText = document.createTextNode(""); control.href = "#"; // so browser shows it as link control.className = "control"; control.appendChild(controlText); Seadragon.Utils.addEvent(control, "click", onControlClick); return control; } function onControlClick(event) { Seadragon.Utils.cancelEvent(event); // don't process link if (!viewer.isOpen()) { return; } // These are the coordinates of europe on this map var x = 0.5398693914203284; var y = 0.21155952391206562; var z = 5; viewer.viewport.panTo(new Seadragon.Point(x, y)); viewer.viewport.zoomTo(z); viewer.viewport.ensureVisible(); } function addOverlays(viewer) { drawer = viewer.drawer; var img = document.createElement("img"); img.src = "_assets/Images/pushpin.png"; $(img).addClass('pushPin'); var overlays = [ { elmt: img, point: new Seadragon.Point(0.51, 0.22) }, { elmt: img, point: new Seadragon.Point(0.20, 0.13) } ]; for (var i = 0; i < overlays.length; i++) { drawer.addOverlay(overlays[i].elmt, overlays[i].point); } } Seadragon.Utils.addEvent(window, "load", init);

    Read the article

  • JQuery, JSF and a4j:commandLink

    - by JQueryNeeded
    Hello ppl, I have a problem with using jQuery Dialog and Ajax submit in JSF. I have the following code for displaying Dialog windows: <script type="text/javascript"> jQuery(function(){ // Dialog jQuery('#dialog').dialog({ dialogClass: 'alert', autoOpen: false, width: 300, height: 150, modal: true, resizable: false, overlay: { backgroundColor: '#000', opacity: 0.5 }, buttons: { "Ok": function() { jQuery(this).dialog("close"); return true; }, "Cancel": function() { jQuery(this).dialog("close"); return false; } } }); // Dialog Link jQuery('#dialog_link').click(function(){ jQuery('#dialog').dialog('open'); return false; }) .hover( function() { jQuery(this).addClass('ui-hover-state'); }, function() { jQuery(this).removeClass('ui-hover-state'); } ); }); </script> It works as it should - it displays box when link is clicked. Now, I have something like this, for deleting something: <a4j:commandLink actionListener="#some.action" reRender="something" onclick="if(!jQuery('#dialog').dialog('open')){return false}" ok, this commandLink is rendered as follows: <a href="#" id="some:long:id:j_id338" name="formName:something:j_id338" onclick="if(!jQuery('#dialog').dialog('open')){return false};A4J.AJAX.Submit('something:something'); return false;" >drop</a> now, after displaying the dialog box, the A4j.AJAX.Submit(..) is executed, is there anyway, that I can for example, pass the whole A4J.AJAX.Submit(...) to "dialog" and execute it from "ok" option? I simply need to execute submit if and only if user clicks OK. Thank you for help JQ

    Read the article

  • jQuery call not working after Isotope filter is implemented

    - by user1374796
    I'm currently using the isotope plugin for a fluid layout, I can successfully filter the content, but after the filters have been called, the rest of my jQuery calls fail to work. Bear with me, I'm still new to jQuery but here's my code: jQuery(document).ready(function(){ jQuery(".pics-hidden").hide(); jQuery('.pics').click(function() { jQuery('#div'+jQuery(this).attr('rarget')).addClass('pics').removeClass('pics-hidden').delay(300).fadeIn(100); jQuery('#projectimages').isotope('reloadItems').isotope(); return false; }); var $container = $('#projectimages'); $container.isotope({ itemSelector: '.pics', animationEngine: 'css', masonry: { columnWidth: 4 } }); $('#menu a').click(function(){ var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector }); return false; }); }); The filter works fine, as does the ('pics') click function, BUT after the filter has been called, the ('.pics') click function now fails to work. Is there a reason for this? Or a way to solve it? Tried all sorts, nothing seems to be working. Any suggestions are greatly appreciated!

    Read the article

  • jquery Plugins/Validation using submitHandler

    - by Eyla
    Greeting, I'm using jquery Plugins/Validation library. I want to allow validation on submitting but I'm not sure where I should insert the code: I know that I can user submitHandler for that but after reading the document I had hard time to implement it so I need your help guys. jquery validation is working ok but the problem that the form still submitted even there are invalid inputs. here is my validation function and I want to know how can I make it to not submit the form if there is invalid input. by the way, I'm using asp.net button for submitting the form. here is my code: $(document).ready(function() { $("#aspnetForm").validate({ rules: { "<%=txtHomePhone.UniqueID %>": { phonehome: true }, "<%=txtMobileHome.UniqueID %>": { mobilephone: true }, "<%=txtFaxHome.UniqueID %>": { faxhome: true }, "<%=txtEmailHome.UniqueID %>": { email: true }, "<%=txtZipCodeHome.UniqueID %>": { ziphome: true }, //work "<%=txtPhonework.UniqueID %>": { phonework: true }, "<%=txtMobileWork.UniqueID %>": { mobilework: true }, "<%=txtFaxWork.UniqueID %>": { faxwork: true }, "<%=txtEmailWork.UniqueID %>": { email: true }, "<%=txtWebSite.UniqueID %>": { url: true }, "<%=txtZipWork.UniqueID %>": { zipwork: true } }, errorElement: "mydiv", wrapper: "mydiv", // a wrapper around the error message errorPlacement: function(error, element) { offset = element.offset(); error.insertBefore(element) error.addClass('message'); // add a class to the wrapper error.css('position', 'absolute'); error.css('left', offset.left + element.outerWidth()); error.css('top', offset.top - (element.height() / 2)); } });

    Read the article

  • jQuery dropdown is really jumpy

    - by Matthew Westrik
    Hi, I'm making a dropdown menu with jquery (some of the code is borrowed from a tutorial by someone, although I forget who...). When I use the dropdown, it slides up and down really fast, and I can't figure it out. What do you think? HTML <div id="nav"> <ul class="topnav"> <li><a class="selected" href="#" title="home">home</a></li> <li><a href="events/" title="events calendar">events</a></li> <li><a href="photos/" title="photo gallery">photos</a></li> <li><a href="staff/" title="faculty">staff</a> <ul class="subnav"> <li><a href="#">Luke</a></li> <li><a href="#">Darth Vader</a></li> <li><a href="#">Princess Leia</a></li> <li><a href="#">Jabba the Hutt</a></li> </ul> </li> <li><a href="contact/" title="contact">contact</a></li> jQuery $(document).ready(function(){ $("ul.subnav").parent() .hover(function() { $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on hover... $(this).parent() .hover(function() { }, function(){ $(this).parent().find("ul.subnav").slideUp('slow'); }); $(this).parent().find("ul.subnav") .hover(function() { }, function(){ $(this).parent().find("ul.subnav").slideUp('slow'); }); }).hover(function() { $(this).addClass("subhover"); }, function(){ $(this).removeClass("subhover"); });

    Read the article

  • How to fix IE ClearType + jQuery opacity problem in this script?

    - by Justine
    Hello, I'm having a rather common problem (or so it seems, after some googling around...) with IE messing both bold text AND transparent pngs while animating opacity using jQuery. You can view the sample here: http://dev.gentlecode.net/dotme/index-sample.html (only occurs in IE, obviously) I've seen some blog posts saying the fix is to remove the filter attribute but I'm not sure how to apply it to the script I'm using since I got it from a tutorial and am still learning jQuery... The script goes as follows: $('ul.nav').each(function() { var $links = $(this).find('a'), panelIds = $links.map(function() { return this.hash; }).get().join(","), $panels = $(panelIds), $panelWrapper = $panels.filter(':first').parent(), delay = 500; $panels.hide(); $links.click(function() { var $link = $(this), link = (this); if ($link.is('.current')) { return; } $links.removeClass('current'); $link.addClass('current'); $panels.animate({ opacity : 0 }, delay); $panelWrapper.animate({ height: 0 }, delay, function() { var height = $panels.hide().filter(link.hash).show().css('opacity', 1).outerHeight(); $panelWrapper.animate({ height: height }, delay); }); return false; }); var showtab = window.location.hash ? '[hash=' + window.location.hash + ']' : ':first'; $links.filter(showtab).click(); }); I would appreciate if someone could go over it and show me how to fix the opacity issue. Will the filter method also fix the trouble I'm having with transparent pngs having pixelated ugly borders like the bold type as well? Thanks in advance for all help!

    Read the article

  • Kill a node in dojo.dnd.source ?

    - by Soulhuntre
    Related to my SO issue at http://stackoverflow.com/questions/3010996/dojo-extending-dojo-dnd-source-move-not-happening-ideas/3012518#3012518 I am now almost done. I have a dnd.Source derived class - we can consider it a dnd.Source for now, that has within it a node that has a specific class. function declare_mockupSmartDndUl(){ dojo.require("dojo.dnd.Source"); dojo.provide("mockup.SmartDndUl"); dojo.declare("mockup.SmartDndUl", dojo.dnd.Source, { markupFactory: function(params, node){ //params._skipStartup = true; return new mockup.SmartDndUl(node, params); }, onDropExternal: function(source, nodes, copy){ console.debug('onDropExternal called...'); // dojo.destroy(this.getAllNodes().query(".dndInstructions")); this.inherited(arguments); var x = source.getAllNodes().length; if( x == 0 ){ newnode = document.createElement('li'); newnode.innerHTML = "Hello!"; dojo.addClass(newnode,"dndInstructions"); source.node.appendChild(newnode); } return true; // return dojo.dnd.Source.prototype.onDropExternal.call(this, source, nodes, copy); } }); } You can see the place I mean from the dojo.destroy that is commented out because it was totally n00b :) If I do this var y = this.getAllNodes().query(".dndInstructions") the nodelist in y absolutely does contain the node. Now I need t kill it, nuke it - get it out of there. Out of the dnd.Source, out of the DOM... gone. Any ideas how to do it safely? It will be the ONLY node in the list at the time we do whatever it is we are goign to do to kill the thing. Thanks!

    Read the article

  • Showing right sub-ul of parent ul menu

    - by Micke
    Hello, i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul> <li class='sub'> <a href='/'>Hem</a> </li> </ul> </li> <li id='community'> <a href='/community'>Community</a> </li> </ul> And this jquery: $("#menu ul > li").mouseenter(function(){ id = $(this).attr("id"); $("#menu #main li").removeClass("active"); $(this).addClass("active"); }).mouseleave(function(){ id = $(this).attr("id"); menu.timers[id] = setTimeout(function(){$("#menu #main li#"+id).removeClass("active");}, 2000); }); What i am trying to acomplish is that when i hover one of the li's in the main ul the child ul of that li should be displayed. and when i move the mouse out of the li or the child ul the menu should be visible for 2 seconds. It works through the main li button but if on the child ul and move out it just disapears, it doesnt wait for two seconds. The waiting two seconds is so you can go in to the menu if you accidentaly move the mouse out of it. Can anybody help me to fix this error? Maybe you have a better solution? Here is also a screenshot on how the menu looks if it helps: screen shot under or click here

    Read the article

  • jQuery Validation Plugin: Invoke errorPlacement function when onfocusout, keyup and click

    - by th3hamburgler
    Hi, I am using the jquery validation plugin and want to use the errorPlacement function to add error messages to the fields title attribute and display just a ? next to the field. This works great when the form is submitted with the submit button but when any of the following events are triggered: - onfocusout - click - onkeyup The validation checks are run but it skips the errorPlacement function and adds the full error message after the field, like the default behaviour. I am using the following code: $("#send-mail").validate({ debug: true, // set this class to error-labels to indicate valid fields success: function(label) { // set text as tick label.html("&#10004;").addClass("valid"); }, // the errorPlacement has to take the table layout into account errorPlacement: function(error, element) { console.log("errorPlacement called for "+element.attr("name")+" field"); // check for blank/success error if(error.text() == "") { // remove field title/error message from element element.attr("title", ""); console.log("error check passed"); } else { // get error message var message = error.text(); // set as element title element.attr("title", message); // clear error html and add cross glyph error.html("&#10008;"); console.log("error check failed: "+message); } // add error label after form element error.insertAfter(element); }, ignoreTitle: true, errorClass: "invalid" });

    Read the article

  • nth child selector in jquery

    - by Praveen Prasad
    <table width="600px" id='testTable'> <tr class="red"><td>this</td></tr> <tr><td>1</td></tr> <tr><td>1</td></tr> <tr><td>1</td></tr> <tr class="red"><td>1</td></tr> <tr><td>1</td></tr> <tr><td>1</td></tr> <tr class="red"><td>this</td></tr> <tr><td>1</td></tr> <tr><td>1</td></tr> <tr class="red"><td>1</td></tr> <tr><td>1</td></tr> <tr><td>1</td></tr> </table> .gray { background-color:#dddddd; } .red { color:Red; } $(function () { $('#testTable tr.red:nth-child(odd)').addClass('gray'); //this should select tr's with text=this, but its not happening }); i want to select all odds inside table which have class=red , but its not happening. please help

    Read the article

  • JSON parse failed

    - by Mesut
    hello i haven an error abour ajax post success. after the success function i added code for lookin for errors ... else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); ... on my php code: echo json_encode(array('msg' => $msg, 'myClass' => $class)); returns back after my function. i checked in firebug and it returns like, response like {"msg":"Kayd\u0131n\u0131z Ba\u015far\u0131l\u0131","myClass":"alert alert-success"} html like {"msg":"Kayd\u0131n\u0131z Ba\u015far\u0131l\u0131","myClass":"alert alert-success"} there is no json tab on firebug and on my ajax code if i comment the dataType: "json", my success function is working but i cant get the response.msg or response.myClass, if i dont comment it, success function is not working, here is the ajax code $.ajax({ type: "POST", url: "index.php?page=addItem&action=addItem&edit=true", data: dataString, success: function(response) { $("#message").html(response.msg); $("#message").addClass(response.myClass); $("#itemForm").fadeOut("slow"); window.setTimeout('location.href = "index.php?page=addItem"', 1000); } });

    Read the article

  • jquery navbar active state stays through refresh

    - by bob
    Hello, I am building a web application and because it has a layout. I don't want to have to create a seperate navigation bar for each page. I am wondering if I can assign an active class to a link that gets clicked on my navbar which will keep the active class even after a page refresh. html <div id="navbar"> <ul id = "main_nav"> <li><%= link_to '', root_path, :class => "home" %></li> <li><%= link_to '', junklists_path, :class => "buy" %></li> <li><%= link_to '', post_junk_path, :class => "sell" %></li> <li><%= link_to '', contact_path, :class => "contact" %></li> </ul> </div> jquery $("#main_nav li a").click(function(){ $("#main_nav li a.active").removeClass('active'); $(this).stop().addClass('active'); }) What options do I have? Thanks in advance!

    Read the article

  • jquery form validation: validation script specified externally

    - by Abu Hamzah
    i have a jquery form validation in the master page and it works fine and i got that working from this article: http://www.dotnetcurry.com/ShowArticle.aspx?ID=310 my question is: if i place the .js to external and add a reference to my page then its not working... it says object expected here is how i have done: in my content page (i am using master page, asp.net ) add in my content page: <script src="myform_validation.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { ValidateMe(this); }); </script> below is in the external .js file: function ValidateMe() { $("#aspnetForm").validate({ rules: { <%=TextBox1.UniqueID %>: { maxlength:1, //minlength: 12, required: true }, <%=TextBox2.UniqueID %>: { minlength: 12, required: true }, <%=TextBox3.UniqueID %>: { minlength: 12, required: true }//, // }, messages: { <%=TextBox1.UniqueID %>: { required: "Enter your firstname", minlength: jQuery.format("Enter at least {0} characters") }, <%=TextBox2.UniqueID %>: { required: "Please enter a valid email address", minlength: "Please enter a valid email address" } , <%=TextBox3.UniqueID %>: { required: "Enter your firstname", minlength: jQuery.format("Enter at least {0} characters") } } , success: function(label) { // set &nbsp; as text for IE label.html("&nbsp;").addClass("checked"); } }); } ;

    Read the article

  • Dropdown menu disappears in IE7

    - by Justine
    A weird problem with a dropdown menu in IE7: http://screenr.com/SNM The dropdown disappears when the mouse moves to a part that hovers above other layers. The HTML structure looks like this: <div class="header"> <ul class="nav> <li><a href="">item</a> <ul><li><a href="">sub-item</a></li></ul> </li> </ul> </div><!-- /header--> <div class="featured"></div> <div class="content"></div> The sub-menu is positioned absolutely and has visibility:hidden, then it's set to visible using jQuery, like so: $(".header ul.nav li").hover(function(){ $(this).addClass("hover"); $('ul:first',this).css('visibility', 'visible'); }, function(){ $(this).removeClass("hover"); $('ul:first',this).css('visibility', 'hidden'); }); I had a problem with the dropdown hiding under other content in IE7, fixed easily by giving the z-index to its parent and other divs: *:first-child+html .header { position: relative; z-index: 2 !important; } *:first-child+html .content, *:first-child+html .main, *:first-child+html .primary *:first-child+html .featured { position: relative; z-index: 1 !important; } Now, I have no idea why the menu disappears when hovered over other divs, you can view the site live here: http://dev.gentlecode.net/ama/ubezpieczenia.html I would love any help, been staring at this code for ages now without any solution. I guess it's just me tunnel visioning already... Thanks in advance for any help!

    Read the article

  • Year split in Quarters using basic jQuery

    - by Alexander Corotchi
    Hi, I have a interesting question: I want to split the year into 4 quarters. What is the idea, A quarter can be different: The HTML Code: <div class="quarterBody"> <span>04-29-2010</span> <span>06-29-2010</span> <span>08-29-2010</span> </div> jQuery (javascript) is total wrong, I hope that w: $(document).ready(function(){ var quarter1 = to make interval (01-01-2010 to 03-31-2010); var quarter2 = to make interval (03-01-2010 to 06-31-2010); var quarter3 = to make interval (06-01-2010 to 09-31-2010); var quarter4 = to make interval (09-01-2010 to 12-31-2010); ... $(".quarterBody span").each(function(){ var date = Date.parse($(this).text()); //to apply some magic code $(this).addClass(quarterNumber); }); }); OUTPUT: <div class="quarterBody"> <span class="Quarter1">02-29-2010</span> <span class="Quarter2">04-29-2010</span> <span class="Quarter3">08-29-2010</span> ... </div> I know right now it is a stupid way, but I hope that somebody can help me, or suggest an idea how to do that in a better way!! Thanks!

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >