Table as a data store
My table is a data table, and I'm contemplating using it as the data store as well, rather than keep a js array of data separately. The cell values are retrived by ajax, then inserted into the table. I'm thinking that the duplication of data (once in the js array, once in the table) is likely to lead to strange results somewhere along the line, where the two data sets get out of synch. It seems to me that jquery makes using a table in this way rather simple (I refer to the jquery selectors in particular).
Windows Safari form 'submit' and javascript onclick event problem
Windows Safari problem: If I execute the line below, updatePriority() below runs, actiontemp.php gets called and my tables update appropriately. <input type="button" value="P" title="Prioritise" onclick="updatePriority('<?php echo $my->id; ?>','<?php echo $ubooks[$i]->book_id; ?>');" /> function updatePriority(UserID,BookID) { $(document).ready( function() { $.post("actiontemp.php", {ui: UserID, bi: BookID, actionType: 'update'}); }); } If I change
Timeouts and animations
Hi, i`m trieing to make a plugin and have a problem. demo The animation is simple, Just click a thumbnail and get to the image you select. But if you click like a maniac the images just go on and de root image doesn`t change and the images just kees sliding in. That`s quite not what i want. And just can`t get a goog idea of changing it. Do you people have an idea how to change the script so i get a fluid animation
The result of offsetParent() when position is fixed
I noticed something odd yesterday—or at least something I didn't expect. When I call offsetParent() on an element with position: fixed, I get back a reference to the body tag rather than the nearest positioned element in the DOM. Is this expected behavior? If so, why? I'd appreciate if someone could explain to me. I am including some sample code that will illustrate what I'm talking about: a relatively positioned div with one absolutely positioned and one fixed positioned child. Load the example
Convert Global Code to jQuery Function
I'm new to jQuery but pretty familiar with JavaScript. I would like to convert the code below to a function that can be used like "$("#member-feedback li").rotateElements()". I've looked at some examples, but I'm not sure where to start. Thanks for your help. var els = []; var idx = 0; var num = 0; function rotateElements() { els.eq(idx).hide(); idx++; if(idx >= num) { idx = 0; } els.eq(idx).fadeIn('slow'); } $(function() { els = $('#member-feedback li'); num = els.length;
img.load and Firefox
Using jQuery 1.4 I'm having a problem with firefox not firing img.load events. These are for local files on a development box: $(document).ready(function() { $('img').load(function() { _myHandler($(this))}); }); function _myHandler($img) { alert('.load fired'); // not happening in FF, only Safari } Is there something extra I need to do to guarantee this event is fired? The API mentioned something about checking .complete, but I couldn't find any example code of that. There was also a discussion
Superfish / TinyMCE (Editor problem)?
I´m using joomla 1.5.15 with a simple template that include a Superfish. Every thing is working fine, expect the editor in the front end. I cant use the image button under the textwindow it opens the image window, but I can not insert or upload a picture. I have seen a discussion on Joomla forum. Do you have solution? Best regards Morten Lindgren DK
.add() strange behavior?
Hi all... I've come across something that I think is a little odd, but I'm not sure if I'm just being dumb. Have a look at this: $(function() { var $div = $("<div>"); var $divs = $(); $divs.add($div); console.log($divs.length); // == 0 $divs = $().add($div); console.log($divs.length); // == 1 }); Logic tells me that $divs.length should be 1 in both cases. I've tested this with 1.3.2 and 1.4 and they both do the same thing, with the exception that in 1.3.2 the $() call creates a jQuery
Accessing the submitted values on the form .submit event
Hi, I have a form which has a few submit buttons, all named SubmitButton so I can pass the clicked button's value through to the submission processor and then act according to which button is pressed. However on the jquery form submit even, I also want to check certain things before I fire the submission off. As the button isn't a "conventional" input I can't check the document object to see which one was clicked, so I need to check the form contents that are about to be submitted, can I do this
Using parameters with functions in plugins doesn't work
So, I have made this sample: http://ceromedia.dk/test.php The problem is, when I call the $.undo function, I pass a custom UndoFn with some parameters, and it works perfectly IF I only remove exactly ONE item and undo that remove afterward. If I remove more than one item, every time I undo that, It restores the last item i removed again and again. It has probably something to do with global namespace etc, but I cant seem to find the bug. So: Remove 3 items, and undo all 3. Then you can see the problem.
Problem with reset value from .html(output)
This event $('#sign').click(SignIn) show input forms in <div id="panel_left"> and when i try to click on input with id="loginuser" it should set value to "" but it's not working, any solutions? <script> $(document).ready(function(){ $("#faq").change(onSelectChange); $("#LinkBox").focus(function() { $(this).attr("value",""); }); $('#sign').click(SignIn); $("#loginuser").focus(function() { $(this).attr("value","");
Table row cloning: remove data from row before clone
I am currently using this function to clone rows in my table when a user clicks 'add row' $(document).ready(function() { $("#addrow").click(function() { var row = $('#answer_options tbody>tr:last').clone(true).insertAfter('#answer_options tbody>tr:last'); $("td:eq(2)", row).text($("#answer_options tbody>tr").length); $("td:eq(4) input", row).attr("name", "choice_text") $("td:eq(5) input", row).attr("name", "blah") return false;
Jcarousal & Menu Lava/Sprites effect on one page
I'm trying to integrate both of these plugins on one single page, but they seem to differ in Library versions they choose & only one can run at a time Lava effect: http://sorgalla.com/jcarousel/ Menu Lava effect: http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/ Can someone help me on this -- thx alot
Animating table Divs?
Hello, this is my first post in site, and i hope i get good impression on the community here Please download and open the attached file, you will see two div columns am trying to animate... my issue is that am trying to animate those two divs without using "floats"... so i use css "display:table;dislay:table-cell;"... to set the divs in their appropriate locations... but sadly, it seems animating them using percentage value gives me a weird animation!.. you can try it your self... i can simply try
conflict problems
having problems with my script I am using lightbox and a fade script could someone point me in the right direction as I am new to jquery! <!--lightbox script--> <script type="text/javascript" src="_common/js/mootools.js"></script> <script type="text/javascript" src="lightbox/lightbox.js"></script> <script type="text/javascript"> window.addEvent('domready',function(){ Lightbox.init({descriptions: '.lightboxDesc', showControls: true}); }); </script> <script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
Self built mini-slideshow jumps/flickers
Hi there, My first post in the jQuery/Zoho forums, so bear with me :) I've built a homemade plugin/function to display a bunch of images as a slideshow. The code is below this message. The images are in an array (imgArray). I have have a.previous and a.next links for the navigation. Only if the user clicks the links again while the image is still fading, it already changes the SRC and then does the fade effect. It kind of looks like flickering. Is there any way to stop/prevent this flickering? Hope
Manipulation .after()
I might be overlooking something obvious here but I am having trouble using the .after() to insert new elements in IE7. It seems to work fine in Firefox (imagine that). At this point I'm simply trying to add a row to a table for each object in the JSON array. The alert shows the element has been added when run in IE but it never renders. Any thoughts on why this would not work in IE? $(document).ready( function(){ $("#ajaxButton").click( function(){ try{ $.getJSON(
.show('') functionality changed in 1.4
I found an (unintended?) change in how 1.4 works: .show('') In <1.4 this triggered the default 'show' with no animation. In 1.4, this causes an animated 'show'. This can be fixed by removing the empty-string argument, but I thought I would post it here in case anyone else comes across this problem. Matt Kruse http://MattKruse.com
How to combine jquery with another js Script
Hi, I (more or less) ok with JQuery, but now, I have a project, here I need to work with another Script, called MTS3Interface.js. Maybe someone knows, that this is needed to work with the viewpoint media player to show 3D Object on a website. The objects can be influenced by javascript and as jQuery offers a wide and great range of functions, I want to combine both. On my web page, I am calling the following: <script type="text/javascript" src="js/actions.js"></script> <script language="javascript"
Pb with selector, context and script tag
Hello I notice a difference between jQuery 1.3 and 1.4 in the jQuery method with context This is a sample code testStr="<div id='container'><div id='divTestId'>test<script>alert('test')</script></div></container>"; var testResult = $("#divTestId", testStr); in 1.3: testResult[0].innerHTML = "test<script>alert('test')</script>" in 1.4: testResult[0].innerHTML = "test" I'm not understand why the script tag disappear.
Internet Explorer object expected line 1 char 1 error
I'm using drupal + jquery and some jquery plugins. When I open site with IE6, IE7, IE8 I'm receiving Javascript error. Error look's like this. Line: 1 Char:1 Error: object expected URL: businessway.am So I have many .js embedded. How to debug? I don't know where this error? How to fix this?
$().focus() VS. $().get(0).focus()
Hi there, I don't quite understand the difference between the jQuery-Event-Trigger-Function .focus() and the native .focus() on DOM-Elements themselves. They both seem to execute the default Browser action, namely put the focus into the element (assuming we are working only with input[type=text]-elements). However, I can't find any call to [DOMNode].focus() inside the jQuery-library-file. Is it possible to trigger the default browser focus event without ever calling the focus-function directly on
find() and jQuery() not finding elements directly under dom with page from $() constructor
Hi -- I'm writing some tests in jspec using jquery, and have come across a problem. This is that when I load the DOM into a var called $page, searches on that $page only return items nested more than one level deep under the body tag. To illustrate, here is my test code (that is failing): http://gist.github.com/285838 And here is the markup it *should* be passing against: http://gist.github.com/285847 Has anyone else come across this & found a fix or a decent workaround? I'm currently id-ing child
jQuery Slidedown/Slideup
I'm sure it's a simple issue, but this slideup/slidedown isn't working as I'd expected. The animation is fine, but just after the slideUp event completes it shows the entire block for a split second before turning invisible. Am I missing something obvious? <div class='outer'>Text Header Here <DIV class='inner'> Some text Here 2 </DIV> </div> <script type='text/javascript'> $('.outer').click(function() { if($(this).find('DIV:visible').length == 0){ $(this).find('DIV').slideDown('slow', function()
Strange error in jQuery 1.4
Morning peoples. I keep getting the following error when i am working with some positioning in jquery Permission denied to access property 'nodeType' from a non-chrome context The code is below that triggers the error... $(document).ready(function(){ $(".stacked-window").live("mouseenter", function(e){ var element=$(this); var rand=$(this).find('.rand').val(); var text=$("#stacked-tooltip-"+rand+"").html(); var height=element.outerHeight(); var left=Math.round(element.offset().left);
jquery nightly
On download page link to jquery-nightly.js referrers to old (v1.4a2pre) version Plz fix this link
.live - listen to the event "create"? :-)
Hi again, My apologie for the spam, but I have another question that I can't seem to find an answer for. Using .live(), I know we can have the engine listen for events that will be triggered on elements that are to be created still. I'm currently looking for a way to automatically execute javascript code on elements when they are created. Is that something that is supported with .live()?
Disabling default submit event
Hi, i got a problem with firefox browser. I've put a onsubmit="return false;" on my html form. I wanna prevent the browser from asking me top password saving bar, when i press send button, 'cause i'm trying to model an ajax form. I've tried the following: [CODE] $('#target').submit(function() { alert('Handler for .submit() called.'); // debug return false; }); [/CODE] but with no luck. How can i prevent that? I'm also using Form Plugin, and my jQuery version is the last released.
modify a request header with jQuery
Hi Folks, does jQuery encapsulate getResponseHeader() and setRequestHeader() somewhere?
infinite loop with jQuery
How do I do a plain old infinite loop with jQuery? Just to fade something in and out forever, without a stack overflow, of course. It's easy enough in javascript but I'm just unclear how to do it with jQuery.
jTruncate / Live()
Hello, I been looking at http://blog.jeremymartin.name/2008/02/jtruncate-in-action.html. It doesn't seem to work for html added to the page after page load. Does anyone know how that would work or if there is a better solution? Thanks! Randy
XML to json
Hello, I am trying to convert an XML object that I have to JSON so I can store it in the browsers cache for later retrieval -- using DOMCached. When I encode the object to JSON using the google json plugin I get an output like this: {"length":187,"0":{"jQuery1264367243616":2315},"1": {"jQuery1264367243616":2316},"2":{"jQuery1264367243616":2317},"3": {"jQuery1264367243616":2318},"4":{"jQuery1264367243616":2319},..... where the jQuery######## are supposed to be sub nodes. How can I best encode this
Is that possible document in iframe uses it's parent's jquery.js ?
hi, guys if I dont want load jquery.js into the iframe again, then, how should I reVAR the "$" method ? how should I reWRITE the "$(document).ready()" ? and how should I use "$.post()" in iframes without another copy of jquery.js ? thx a lot ~
Best way to populate a form with json object
Any suggestions? Found this plugin as a solution, which works: http://www.keyframesandcode.com/code/development/javascript/jquery-populate-plugin/ And this suggestion, which I can't get to work: http://stackoverflow.com/questions/1859784/cannot-populate-form-with-ajax-and-populate-jquery-plugin What do you think?
jquery .replaceWith() not playing nice with .clone() in IE... why?
I'm using jQuery to created a linked TOC that appears in a dialog box. The function I wrote to do so finds all the h4's in the page and gives them ids to link to adds some numbering display info clones them turns the clones into lis wraps the inner text in anchor tags finds the anchors adds a click function to the anchors to close the dialog adds titles and hrefs to the anchors so the links point to the original h4s goes back to the lis appends the lis to a ol the in dialog div However, in IE7, the
What is the return value of .wrap() ?
Hi, I took a wild guess and thought the following code would return the new wrapper as an object: var objWrapper = $("p").wrap("<div />"); and that I could continue working with objWrapper, for example: objWrapper.css("padding", "5px"); but I couldn't. What I need to do is: $("p").wrap("<div id='wrapper' />"); var objWrapper = $("#wrapper"); objWrapper.css("padding", "5px"); This, to me, looks like an extra roundtrip to the DOM. So my question is: Is this by design, or am I doing something wrong?
Need to save multiple text to a variable
I need the text in the function to save to a variable. It will run through each of the child text and than attach to data. I'm willing to switch stuff up/rewrite a different way, I just need to know a way of getting this done $("#navigation").click(function(){ var data; $("#navigation ul span li").each(function(){ data = data + $(this).find(':first').text() }) alert(data) })
Why does function only work once?
Having problems that my function only seems to execute once...code: <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript" > $(document).ready(function(){ $("*[id^=\'ST\']").each(function() { $(this).click(function() { string = this.id.substring(2); string2 = "#" + string; $(string2).load('tips/'+this.id+'.txt'); }); }); }); </script> </head> <body> <a id="STtextfield">[+]</a>
Navigation menu
Hi, I'm trying to design a navigation menu for my site, similar to the one you can see on www.o2.co.uk (Explore, Shop, Support) This is my code so far which works - sort of: $(".linkblock").hide(); $(".expandexplore").toggle( function () { $("#exploreblock").slideDown('slow'); }, function () { $(".linkblock").slideUp('fast')(); } ); $(".expandservices").toggle( function () { $("#servicesblock").slideDown('slow'); }, function () { $(".linkblock").slideUp('fast')();
jQuery and JSF 2.0
Hi I have used jQuery extensively in my PHP websites. Now, I am into Java using JavaServer Faces (JSF), and still would like to stick to jQuery. I am looking for any aritcles / blogs /tutorials giving some lead on how to use jQuery with JSF 2.0. The Google didn't help much. Could you please share me the urls, if there are any? Thanks Srikanth
Next Page