Search Results

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

Page 14/27 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • How can I make a jQuery UI 'draggable()' div draggable for touchscreen?

    - by artlung
    I have a jQuery UI draggable() that works in Firefox and Chrome. The user interface concept is basically click to create a "post-it" type item. Basically, I click or tap on div#everything (100% high and wide) that listens for clicks, and an input textarea displays. You add text, and then when you're done it saves it. You can drag this element around. That is working on normal browsers, but on an iPad I can test with I can't drag the items around. If I touch to select (it then dims slightly), I can't then drag it. It won't drag left or right at all. I can drag up or down, but I'm not dragging the individual div, I'm dragging the whole webpage. So here's the code I use to capture clicks: $('#everything').bind('click', function(e){ var elem = document.createElement('DIV'); STATE.top = e.pageY; STATE.left = e.pageX; var e = $(elem).css({ top: STATE.top, left: STATE.left }).html('<textarea></textarea>') .addClass('instance') .bind('click', function(event){ return false; }); $(this).append(e); }); And here's the code I use to "save" the note and turn the input div into just a display div: $('textarea').live('mouseleave', function(){ var val = jQuery.trim($(this).val()); STATE.content = val; if (val == '') { $(this).parent().remove(); } else { var div = $(this).parent(); div.text(val).css({ height: '30px' }); STATE.height = 30; if ( div.width() !== div[0].clientWidth || div.height () !== div[0].clientHeight ) { while (div.width() !== div[0].clientWidth || div.height () !== div[0].clientHeight) { var h = div.height() + 10; STATE.height = h; div.css({ height: (h) + 'px' }); // element just got scrollbars } } STATE.guid = uniqueID() div.addClass('savedNote').attr('id', STATE.guid).draggable({ stop: function() { var offset = $(this).offset(); STATE.guid = $(this).attr('id'); STATE.top = offset.top; STATE.left = offset.left; STATE.content = $(this).text(); STATE.height = $(this).height(); STATE.save(); } }); STATE.save(); $(this).remove(); } }); And I have this code when I load the page for saved notes: $('.savedNote').draggable({ stop: function() { STATE.guid = $(this).attr('id'); var offset = $(this).offset(); STATE.top = offset.top; STATE.left = offset.left; STATE.content = $(this).text(); STATE.height = $(this).height(); STATE.save(); } }); My STATE object handles saving the notes. Onload, this is the whole html body: <body> <div id="everything"></div> <div class="instance savedNote" id="iddd1b0969-c634-8876-75a9-b274ff87186b" style="top:134px;left:715px;height:30px;">Whatever dude</div> <div class="instance savedNote" id="id8a129f06-7d0c-3cb3-9212-0f38a8445700" style="top:131px;left:347px;height:30px;">Appointment 11:45am</div> <div class="instance savedNote" id="ide92e3d13-afe8-79d7-bc03-818d4c7a471f" style="top:144px;left:65px;height:80px;">What do you think of a board where you can add writing as much as possible?</div> <div class="instance savedNote" id="idef7fe420-4c19-cfec-36b6-272f1e9b5df5" style="top:301px;left:534px;height:30px;">This was submitted</div> <div class="instance savedNote" id="id93b3b56f-5e23-1bd1-ddc1-9be41f1efb44" style="top:390px;left:217px;height:30px;">Hello world from iPad.</div> </body> So, my question is really: how can I make this work better on iPad? I'm not set on jQuery UI, I'm wondering if this is something I'm doing wrong with jQuery UI, or jQuery, or whether there may be better frameworks for doing cross-platform/backward compatible draggable() elements that will work for touchscreen UIs. More general comments about how to write UI components like this would be welcome as well. Thanks!

    Read the article

  • jQuery onmouseover + onmouseout / hover on two different divs

    - by ahmet2106
    Hello everybody, I've got a Problem: Here a part of my HTML: <div id="div_1"> Here Hover </div> <div id="div_2"> Here content to show </div> And here a part of my jQuery Script: jQuery('#div_2').hide(); jQuery('#div_1').onmouseover(function() { jQuery('#div_2').fadeIn(); }).onmouseout(function(){ jQuery('#div_2').fadeOut(); }); The Problem: If i hover on the div_1, the div_2 is shown, if i hover out, the div_2 is hidden, but: If i hover first on div_1 and then go over div_2, the div_2 is hidden fast. I've tried this with jQuery.addClass(); after mouseout in div_1, but nothing is changing. I dont want do make the second div in the first div... Is there another way with jQuery? Thx Ahmet

    Read the article

  • Jquery droppable live disabling/enabling

    - by Cameron
    I have a some draggables in a list of droppables (1 draggable per droppable li). When I move a draggable from one droppable to another free droppable, I want to diable the receiving droppable, and enable the droppable it is leaving from. In firebug the droppable class gets removed – but the functionality of the droppable remains. I have a feeling I need to use live() somehow, but could use a leg-up. $(function() { $(".user").draggable({ revert : true, revertDuration : 200 }); $("li.droppable").droppable({ accept : ".user", hoverClass : "drophover", drop: function(event, ui) { var position = this.getAttribute("id").replace("position_", ""), user_id = ui.draggable.attr("id").replace("user_", ""); droppable = this parent = ui.draggable.parent() $.ajax({ url : "users/"+user_id+"", type : "POST", dataType: "JSON", data : ({ "position" : position, "_method" : "PUT" }), success : function() { $(ui.draggable).parent().addClass("droppable"); $(ui.draggable).appendTo(droppable); $(parent).removeClass("droppable"); } }); } }); });

    Read the article

  • Execute JavaScript function on a dynamic element (AJAX).

    - by jartaud
    Hello i have this following function: ... var model = $("#carModel"); .... model.change(validModel); function validModel(){ if(model.val() == undefined){ model.addClass("errorJS"); return false; }else{ model.removeClass("errorJS"); return true; } } I am getting carmodel id from a select box generated after an AJAX call. I can get its value in the Firebug console, but the function doest not execute. Even tough i use model.livequery(validModel); // The errorJS class put a red border in a element, if the function returns false

    Read the article

  • remove cssclass from one anchor and assign to another in jquery...

    - by Pandiya Chendur
    Here are my anchors, <a ID="lnkbtn0" class="page-numbers" href="#">1</a> <a ID="lnkbtn1" class="page-numbers" href="#">2</a> <a ID="lnkbtn2" class="page-numbers" href="#">3</a> <a ID="lnkbtn3" class="page-numbers" href="#">4</a> And my click function i am adding a cssclass to show that it is the current anchor $("a.page-numbers").click(function() { $(this).addClass('page-numbers current'); }); What happens is when i click the next anchor the same class has been added to the current and the previous anchor... What can be done to remove the cssclass page-numbers current and assign cssclass page-numbers to the previous/all other anchors without changing the current one....

    Read the article

  • How do I fix incorrect inline Javascript indentation in Vim?

    - by Charles Roper
    I can't seem to get inline Javascript indenting properly in Vim. Consider the following: $(document).ready(function() { // Closing brace correctly indented $("input").focus(function() { $(this).closest("li").addClass("cur-focus"); }); // <-- I had to manually unindent this // Closing brace incorrectly indented $("input").blur(function() { $(this).closest("li").removeClass("cur-focus"); }); // <-- This is what it does by default. Argh! }); Vim seems to insist on automatically indenting the closing brace shown in the second case there. It does the same if I re-indent the whole file. How do I get it to automatically indent using the more standard JS indenting style seen in the first case?

    Read the article

  • jQuery: Simple menu

    - by JamesBrownIsDead
    I'm trying to learn jQuery by implementing a simple menu. I've got <div> elements that act as buttons and have links in them. I'm trying to add onclick events to the divs that navigate the browser to the link's address in the div. This is basically my pseudo-code. What would the real code be? How can I improve this? Any feedback appreciated! // Iterate over each menu button $('.masterHeaderMenuButton').each(function () { // Get the link in each button and set the button's onclick to // redirect to the link's address var url = $('a', this).attr('href'); this.click(function () { window.location.href = url; }); // If the user is on the page for the current button, hilight it if (window.location.href === url) { $('a', this).addClass("masterHeaderMenuButtonSelected"); } });

    Read the article

  • echoing javascript when an ajax funtion is called

    - by Roland
    I'm doing a ajax call via the normal jquery ajax funtion My ajax looks as follows jQuery('#yt10').live('click',function(){jQuery.ajax({'data':{'set':$("#booking_set_id1").val(),'setStat':$("#booking_stockStatus").val(),'setNum':$("#booking_setNum").val()},'beforeSend':function(){ if($("#booking_set_id1").val() == "" || $("#booking_stockStatus").val() == "" || $("#booking_setNum").val() == ""){ $("#error").addClass("flash-error"); $("#error").html("Please fill in all relevant set details before adding a set"); return false; } },'dataType':'html','success':function(data,status){ $("#mainrow").show(); $("#error").removeClass("flash-error"); $("#error").html(""); $("#setTable tr:last").after(data); $("#booking_set_id1").val(""); $("#booking_stockStatus").val(""); $("#booking_setNum").val(""); },'url':'/booking/newSet','cache':false});return false;}); Now the function newSet needs to echo javascript to the bowser but somehow jquery filters the javscript out. Is it possible to echo javascript via ajax

    Read the article

  • images are getting clipped when Jquery animate opacity is used in IE

    - by Raja
    I use the function given below: function rotate() { //Get the first image var current = ($('div#rotator ul li.show') ? $('div#rotator ul li.show') : $('div#rotator ul li:first')); //Get next image, when it reaches the end, rotate it back to the first image var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') : current.next()) : $('div#rotator ul li:first')); //Set the fade in effect for the next image, the show class has higher z-index next.css({ opacity: 0.0 }) .addClass('show') .animate({ opacity: 1.0 }, 1000); //Hide the current image current.animate({ opacity: 0.0 }, 1000) .removeClass('show'); }; It does a slide show of images. It works perfect on Firefox and Google Chrome but clips the images in IE 7 and IE 8. Any help is much appreciated. Thanks in advance.

    Read the article

  • jQuery Toggle with Cookie

    - by Cameron
    I have the following toggle system, but I want it to remember what was open/closed using the jQuery cookie plugin. So for example if I open a toggle and then navigate away from the page, when I come back it should be still open. This is code I have so far, but it's becoming rather confusing, some help would be much appreciated thanks. jQuery.cookie = function (name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options = $.extend({}, options); options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; // var showTop = $.cookie('showTop'); if ($.cookie('showTop') == 'collapsed') { $(".toggle_container").hide(); $(".trigger").toggle(function () { $(this).addClass("active"); }, function () { $(this).removeClass("active"); }); $(".trigger").click(function () { $(this).next(".toggle_container").slideToggle("slow,"); }); } else { $(".toggle_container").show(); $(".trigger").toggle(function () { $(this).addClass("active"); }, function () { $(this).removeClass("active"); }); $(".trigger").click(function () { $(this).next(".toggle_container").slideToggle("slow,"); }); }; $(".trigger").click(function () { if ($(".toggle_container").is(":hidden")) { $(this).next(".toggle_container").slideToggle("slow,"); $.cookie('showTop', 'expanded'); } else { $(this).next(".toggle_container").slideToggle("slow,"); $.cookie('showTop', 'collapsed'); } return false; }); and this is a snippet of the HTML it works with: <li> <label for="small"><input type="checkbox" id="small" /> Small</label> <a class="trigger" href="#">Toggle</a> <div class="toggle_container"> <p class="funding"><strong>Funding</strong></p> <ul class="childs"> <li class="child"> <label for="fully-funded1"><input type="checkbox" id="fully-funded1" /> Fully Funded</label> <a class="trigger" href="#">Toggle</a> <div class="toggle_container"> <p class="days"><strong>Days</strong></p> <ul class="days clearfix"> <li><label for="1pre16">Pre 16</label> <input type="text" id="1pre16" /></li> <li><label for="2post16">Post 16</label> <input type="text" id="2post16" /></li> <li><label for="3teacher">Teacher</label> <input type="text" id="3teacher" /></li> </ul> </div> </li>

    Read the article

  • jquery attr problem

    - by shanmugam
    function rotateimg(ulid,showid,linkid) { var cur = $("#"+ulid+" li.current"); var nxt = cur.next("li"); if (nxt.length == 0) { nxt = $("#"+ulid+" li:first"); } cur.removeClass("current"); nxt.addClass("current"); var img_value=nxt.attr("id").substring(11); var img_title=nxt.attr("title"); var img_id = nxt.attr("name").substring(17); var alink=nxt.attr("rel"); $("#"+linkid).attr("href",alink); $("#"+ulid+" li div").css("background-color", "#000000"); nxt.find("div").css("background-color", "#333333"); setimg(img_value,showid,img_title); } var lt=setInterval("rotateimg('lnews','show_images_event','lnewslink')", 5000); in this code. i am getting this error nxt.attr("id") is undefined pls any one help me

    Read the article

  • Jquery Tabs - Change css depending on a specific tab

    - by Jeff Dias
    So, I am working in this page http://universidadedoingles.com.br/text-tabs/tabs-text.html As you guys can see, I have four tabs and an arrow right below, I need to do that the arrow go below the selected tab, if a click on tab 3, that arrow should go below tab 3, simple as that! but I don`t know! You also can see that when the page loads on tab 1 and you click on tab 2 the effect I want works pretty well, here`s the jquery I am using for that: $(document).ready(function() { $("a.tab2").click(function() { $(".arrow-spacer").addClass("tabs2"); }); }); That`s it, thank you vey much for any kind of help. p.S - i am using a mac, so theres no IE for testing yet, this looks good in Safari and Chrome.

    Read the article

  • Jquery display image problem

    - by Sergio
    Hello, I have PHP page where users can upload photos (using Ajax & PHP script). Those uploaded photos (thumbs) are shown after upload in DIV below upload field. Then, after hitting send button I want to clone that DIV at that same page at message board, bellow other messages with or without uploaded photos. When I try to do that with: var pht = $("#photos").clone().addClass('p_pht'); and try to display sent photos bellow sent message like this: $("div#wall").append('<div class=msg>'+ message +'</div><div class=n_pht>'+ pht +'</div>'); I get Jquery error message "[object Object]" in place where the photos should be displaying. What am I doing wrong?

    Read the article

  • jQuery: Cannot change style of element after selected

    - by JamesBrownIsDead
    Here is my code. Where you see "alert([...]);", an alert pops up. Why doesn't the CSS style change? The 'click' event fires, too! resolveSideMenuAddress: function () { var firstLink = $("#masterHeaderMenu .masterHeaderMenuButton a:first"); function select(link) { alert('i alert'); link.css({ 'color': '#9a4d9e', 'cursor': 'default' }); alert('color and cursor not changed'); link.click(function () { alert('click'); return false; }); } if (window.location.pathname === firstLink.attr('href')) { alert('i alert'); select(firstLink); } } I've tried addClass() and can't change the color of the link that way either.

    Read the article

  • jQuery - Iframe validation - cannot get values

    - by Henry
    See demo: http://tinyurl.com/3xow97t The editor is under development. Now we check if it has an value - this works well with all form fields that have the class .required... but it does not work with the iframe. the iframe has a div with id #content. $('form .meet').focus(function() { $('iframe').each(function() { ** if($(this).contents().find('#content').val() == '') { ** $(this).addClass('warning'); } }) }); That means it should add the class .warning if the iframe is empty. But it always does, so what am i doing wrong? Does it not work, because the JS does not see the text i currently typed in? ^^ Regards Henry

    Read the article

  • Saving an NSMutableArray of custom Objects

    - by aahrens
    I have a custom class that is used as a wrapper to an NSMutableArray @interface AllCourses : NSObject { NSMutableArray *arrClasses; } The array above stores Objects of another custom class. @interface Course : NSObject { NSString *className; NSString *classGrade; NSInteger creditHours; } I use the method below to add Course objects to my AllCourses //Adds a new Course to the total Courses -(void) addClass:(Course *)aCourse{ [arrClasses addObject:aCourse]; } What's going to be the best way to save the arrClasses MutableArray in AllCourses so that when my app loads it can keep the saved data the user already entered and populate it?

    Read the article

  • Complicated jQuery .hover Work

    - by Paul Herz
    The following code is giving me a lot of trouble. To note, .hover changes the background image. Firstly, how can I combine the two with .hover rather than a separate mouseenter and mouseleave? Second, How can I make it so that while the div is shifting upwards, the background image is simultaneously fading? $('div.designbox.orangehello').mouseenter(function() { $('div.designbox.orangehello').animate({ top: '-=10', }, 55, function() { $(this).addClass('hover'); }); }); $('div.designbox.orangehello').mouseleave(function() { $('div.designbox.orangehello').animate({ top: '+=10', }, 55, function() { $(this).removeClass('hover'); }); });

    Read the article

  • using document.createDocumentFragment() child dom elements that contain jQuery.data

    - by taber
    I want to use document.createDocumentFragment() to create an optimized collection of HTML elements that contain ".data" coming from jQuery (v 1.4.2), but I'm kind of stuck on how to get the data to surface from the HTML elements. Here's my code: var genres_html = document.createDocumentFragment(); $(xmlData).find('genres').each(function(i, node) { var genre = document.createElement('a'); $(genre).addClass('button') .attr('href', 'javascript:void(0)') .html( $(node).find('genreName:first').text() ) .data('genreData', { id: $(node).find('genreID:first').text() }); genres_html.appendChild( genre.cloneNode(true) ); }); $('#list').html(genres_html); // error: $('#list a:first').data('genreData') is null alert($('#list a:first').data('genreData').id); What am I doing wrong here? I suspect it's probably something with .cloneNode() not carrying over the data when the element is appended to the documentFragment. Sometimes there are tons of rows so I want to keep things pretty optimized, speed-wise. Thanks!

    Read the article

  • Highlight field in source code pane of Findbugs UI

    - by Ryan Fernandes
    I'm using a class that extends BytecodeScanningDetector to check for some problematic fields in a class. After detecting whether the field is problematic, I add it to the bug report like below: Once I run findbugs, it identifies the bug, lists it in the left pane, but does not highlight the corresponding source line. Any hints/help on this will be very appreciated. public void visit(Field f) { if (isProblematic(getXField())) { bugReporter.reportBug(new BugInstance(this, tBugType, HIGH_PRIORITY) .addClass(currentClass) //from visit(JavaClass) .addField(this)); } } public void visit(JavaClass someObj) { currentClass = someObj.getClassName(); } P.S. I tried posting this on the findbugs list but... no joy.

    Read the article

  • jQuery Delay Question

    - by Fuego DeBassi
    <script type="text/javascript"> $(document).ready(function() { $(".module .caption").hide(); $(".module").hover(function() { $(this).find(".caption").slideDown().end().siblings('.module').addClass('under'); },function() { $(this).find(".caption").slideUp().end().siblings('.module').removeClass('under').delay(10000); }); }); </script> This works great, except the .delay doesn't work, is my syntax wrong? I'm just trying to accomplish haveing the .removeClass("under") delayed by a second or two when the mouse un-hovers. I don't want to delay the slideUp. Any ideas?

    Read the article

  • Retrieve Table Row Index of Current Row

    - by Jon
    Hi Everyone, I am trying to validate a text input when it loses focus. I would like to know which row of the table it is in. This is what I have so far and it keeps coming back as undefined. Any ideas? $("div#step-2 fieldset table tbody tr td input").blur(function() { var tableRow = $(this).parent().parent(); if ($.trim($(this).val()) == "") { $(this).addClass("invalid"); alert(tableRow.rowIndex); $(this).val(""); } else { $(this).removeClass("invalid"); checkTextChanges(); } });

    Read the article

  • jQuery not replacing text in ReportViewer

    - by firedrawndagger
    I'm trying to replace text that I got back in the ReportViewer using jQuery. My div, wrapped in the table cell, display "empty" as text - which I plan on replacing with my own formatted text on the client side. I can use jQuery just fine to set a class on the div (which is inside a td element). Example: jQuery('div:contains("empty")').addClass('replacetext'); But for some reason I cannot do this: jQuery('div:contains("empty")').replaceWith('<div>Hello World</div>'); I tried this out on some other elements on the page and jQuery does work... but it seems like this issue is ReportViewer (I'm using 2008) specific.

    Read the article

  • Why trigger fired only once when running on a JQuery Object?

    - by Shlomi.A.
    Hi I got an array. I'm running over it for (i = 0; i < sugestionsArray.length; i++) { $('li.groupCode' + sugestionsArray[i] + ' span').addClass('checkedInput'); $('option[value=' + sugestionsArray[i] + ']').attr('selected', 'selected'); } And this loop runs 3 times perfectly, adding classname and playing with the option. instead of adding a clasname, i'm trying to trigger a click over the span $('li.groupCode' + sugestionsArray[i] + ' span').trigger('click'); which in his turn has a click event bind to it using jq as well Span.click(function() {}) for some reason my loop breaks after the first click. he is leaving the loop and don't continue to the next 2 loops after him. only the first span is been clicked. does anyone has an idea?

    Read the article

  • Add client side javascript code and ASP.Net validation on a asp.net button

    - by Vinni
    Hello guys, I wanted to write javascript code on "OnClientClick" of the asp.net button and also I want the asp.net validation to be run for that button. but when i mix these both validation is not working. please help me out. Below is my code ASPX <asp:Button ID="btnAddToFeatureOffers" runat="server" Text="Add to Feature Offers" OnClick="btnAddToFeatureOffers_Click" ValidationGroup="vgAddOffer" OnClientClick="add();" /> javascript function add() { var selectedOrder = $('#ctl00_MainContent_ddlFeaturedHostingType option:selected')[0].index; var offer = $('#<%=txtOrder.ClientID%>').val(); var a = $("<a>").attr("href", "#").addClass("offer").text("X"); $("<div>").text(offer).append(a).appendTo($('#resultTable #resultRow td')[selectedOrder - 1]); }

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >