Make a function re-usable ?
So i have 2 functions that actualy do exactly the same but on an other event. It are pretty "large" scripts and so i would like to make 1 out of it, but i don't know how to do that and i think it will come in handy a lot if i knew how. So who could show me please ? var calculate = function(){ $('#loading').hide(); // ladenprentje verstoppe bij t begin $(".code").live("keypress", function(e){ if (e.keyCode == 9 ) { // rij waarin we zitte zoeken en opslaan var
The Official jQuery Podcast - Request for Audience Questions
We will be recording tomorrow night Thursday, February 18th and we would love it if we got some audience questions. So please either ask here on the forum any question that you would like answered from the jQuery Team. So far it'll be Rey Bango and I and possibly a few more of the Developer Relations (aka Evangelists). In addition to submitting your question here you can call in your question to (804) 4jQuery, (804) 457-8379. (it's a google voice number and it'll dump you right to voice mail).
jQuery 1.4.1, IE7, AJAX form
Hi, I have a form, which is loaded via ajax into the site and is submitted via ajax into rails. I use the jrails-helper, which generates a form like this: <form onsubmit="$.ajax({data:$.param($(this).serializeArray()) + '&authenticity_token=' + encodeURIComponent('...'), dataType:'script', type:'post', url:'...'}); return false;" method="post"> ... </form> Using jQuery 1.4.1 and IE7, none of the values in the form (hidden fields, check boxes) is sent to rails... Switching back to 1.3.2 solved
drag and drop problem with helper
I have a problem with the drag and drop function. I would like to drag a div and when i drop it i want a copy of the div to append to the area and i want to be able to do the same process over and over again. example: http://jqueryui.com/demos/draggable/#sortable I want my div to behave the same way but without the "sortable" function, instead i want to put the div wherever i want. I have tried to do just that for several days, without success. So please help me out.
How to bind droupdownlist using jquery
Hi,All I am using asp.net(3.5) and sql server(2005).how to bind droupdown list get data from sql server. using jquery and asp.net. Cheers, Sanjay
Need help with sum.toFixed(2)
Hello everyone, I am having trouble finding an answer to my problem. I am currently using a calculator plug-in script provided by Pengoworks.com. Everything is works very well. Howerver what I am trying to do is display the the sum within an input field instead of a "div". Here is the last bit of code: // define the finish callback, this runs after the calculation has been complete function ($this){ // sum the total of the $("[id^=total_item]") selector
IE8 Scrollable TBODY - Scroll Event not working.
Hello, Has anyone tried to bind the scroll event to a scrollable tbody in IE8 and it worked? If so, please let me know how you did that, because while it works in FF 3.6, it does not work in IE8 (unless I'm doing something wrong.) I've searched quite a bit for this and couldn't find anyone that had a question on this. Thanks, adobepro. Example: I have a table with a scrollable tbody, and what I want to do is bind a scroll event to the tbody to find when the user had scrolled to the bottom of the
Accordian navigation loading SWF's into Div
Hi I am wanting to create a web page with a vertical navigation panel on the left of the page and because this will includes 'categories' and 'sub categories' (see below) CATEGORY 1 sub category 1a sub category 1b sub category 1c sub category 1d sub category 1e CATEGORY 2 sub category 2a sub category 2b sub category 2c sub category 2e Ideally I would want the Category tabs when clicked to reveal the sub categories (Accordian) I have the Spry Accordian set in a Div at the moment in Dreamweaver and
Add info to div without rewriting HTML
Hey, I'm working on www.acars-netherlands.com. We do every 5 seconds an Asynchronious XML-HTTPRequest. The result of this request is displayed in the div messages. The newest results must be displayed at the top of the page. The code that we now have is: var oldmessages = $("#messages").html(); $("#messages").html(ajaxreply + oldmessages); If we use this, JQuery is rewriting the HTML into the div and a new request to the images is made. Otherwise if we use .before(), the messages are written outside
Porblems accesing array elements; possible scope issue.
Hi I'm completely stumped, can someone help please? The below code executes without errors in chrome and firefox but the alert returns 'undefined' even though images[] is populated correctly with string paths when I test from the browser consoles. can anyone see the problem? <script type="text/javascript"> var images = new Array(); $(document).ready(function() { $.getJSON("images/research/getImgs.php", function(json){ for(var i=0;i<json.length;i++) { images[i] = json[i]; } });
How to fadeIn & fadeOut a function?
Hi all, I'm 3 hours stuck on trying to find a code wich allows me to fadeIn and fadeOut in a mouseover/mouseout function with a var in it. I tried a lot of things adding this piece of code I got into it: $ (this).fadeIn(1000); $ (this).fadeOut(1000); This is what I got for now: $(function() { $(".fade2 img") // I want this fade in .mouseover(function() { var src = $(this).attr("src").match(/[^\.]+/) + "_2.gif"; $(this).attr("src", src); }) // I
problem using confirm dialog
I have in my page a button that onclick opens a dialog (add-to-blacklist_dialog). In this dialog, the user has a textbox to enter some text and then hits "Ok" on the Ok click, a second dialog (confirm_word_add_dialog) opens to confirm what the user entred. The problem is when the user hits "cancel" and returns to the first dialog and changes the text the hits "Ok" of the first dialog, the "new text" entred is not taken into consideration and i still have the old text. Any Ideas?? thanks in advance
jquery keyboard + mouse click
Hi, is there any solution how i can intercept an event like SHIFT+LeftMouseClick ?
Removing elements from a clone
Hi, I have a block of HTML that I am cloning, as I want to manipulate it to remove an element, so that I can then append that new HTML somewhere else on the page. E.g.: <div id="container"> <p>Some sample text to be filled in later...</p> <a id="copy_btn" href="#">copy text</a> </div> Then in the jQuery, I have tried many different ways of removing stuff from that clone, but with no luck. E.g. var cont = $('#container').clone(); $(cont).remove("copy_btn").appendTo("body"); There
Coding performance: Closure vs Prototype vs 'Classes'
Hi, I see that jQuery is heavily based on closure-style coding. I'm not too experienced in js performance semantics and would like to hear your thoughts. After reading about closures a bit more, it seems to be inefficient when an object is created many times; where the closure functions are created in the constructor. However, in my scenario, I wish to create one object only once, but frequently call the routines in it. Any thoughts of performance comparisons for the following implementations: (Although
Issue with animation
hi, I've got a nested list and the jQuery script shown below to show/hide each list separately (+/- link) and to show/hide all lists at once (show all/hide subcategories). When I use show() and hide(), it works as expected, but when I use animations(eg, show('slow') or slideDown()), I get a strange issue. When doing: 1-show all 2-hide asian 3-hide all 4-show asian all subcategories of asian are visible, thought everything is closed in step 3. It seems that the problem is in the line $(this).next().show('slow');
Need Help ( Iframe)
I have my page index.php which include the another page index2.php by using iframe tag. index2.php has jquery links, when I aceess www.myhost.com/index.php & click on the link contained in index2.php , the jquery opens in iframe , how can I make it open in parent window? Pls Help. Thanks Poonam
problem using attr
I have in my page a button that onclick opens a dialog (add-to-blacklist_dialog). In this dialog, the user has a textbox to enter some text and then hits "Ok" on the Ok click, a second dialog (confirm_word_add_dialog) opens to confirm what the user entred. The problem is when the user hits "cancel" and returns to the first dialog and changes the text the hits "Ok" of the first dialog, the "new text" entred is not taken into consideration and i still have the old text. Any Ideas?? thanks in advance
Slideshow with variable height
Hello there. I've been successful with creating slideshows, however I am trying to accomplish a slideshow that has a variable height so that the content that goes below the slideshow will move up and down accordingly. An example I found can be seen here: http://odopod.com/work/vsnax/ If you click "take a look" and content to click through you'll see. Does anyone have any documentation on how to accomplish this? Much appreciated. Thanks so much!
Mr. Selector, the neverending story
Hi Folks, I read a lot about different ways and techniques to select DOM elements with jQuery. Among other articles, Paul Irish's 'Anti-Patterns for Performance' presentation. it looks like there are thousands ways to select something within the DOM (syntax/functions/parameters). quick example: <HTML> <HEAD></HEAD> <BODY> <DIV class="container"> <DIV id="myelement"></DIV> </DIV> </BODY> </HTML> $("div#myelement") $("div.container > div#myelement") $("div#myelement", "div.container")
Animations in firefox are choppy due to seemingly unrelated tags and/or attributes
(My apologies if this post becomes a duplicate. The first one I made was awaiting moderation and did not appear.) OS: Mac OS X 10.6.2 Browser: Firefox 3.6 I have noticed that when doing animations (moving an item across the screen), at times the animations are choppy in firefox. It is hard to explain how to reproduce this problem as it seems it is dependent on random elements of the page. I have tested the same page in Opera, Safari and IE and the animations are very smooth. The following is a
Selecting Groups of elemets
I am trying to easily fix 100+ blog posts where the customer has <pre> tags to format code. the issue is in wordpress when you hit enter you are given a new <p> tag, and setting the format to preformatted outputs code like this <pre>line</pre> <pre>line</pre> <pre>line</pre> <pre>line</pre> <pre>line</pre> <p> Paragraph Text</p> <pre>line</pre> <pre>line</pre> <pre>line</pre> I would like to combine each set of pre tags into one ( or wrap each set in a div) <pre> line </br> line </br>
Why does my function tha opens a dialog box only worked once?
Newbie here, I have a button that opens up a dialog box. When "search" in the dialog box is clicked, another dialog box is supposed to open. Everything works great ONE TIME. If I try clicking on the button again, the first dialog box opens, but when I click on "search" again, nothing happens. first time: Clicking on "more search options"->Opens Dialog box 1. Clicking "search"-> Opens dialog box 2. Everything is okay! Second time: Clicking on "more search options"-> Opens Dialog box 1. clicking "search"->
do{}while error or bug?
maybe anyone can tell is this an error or i'm doing something wrong. as i understand there must value 123 in the #footer div, but i get 444 (this div is made just to see the values of var "w" at all stages, all i need is string 6 in my code) ct_all=3 w=1 do{ toto='#center_' + w $.get("include/view_function.php", { hot: w},function(data){$(toto).load(data + " .tp_offers_tbl"); $('#footer').append(w) }); w++ }while(w<=ct_all)Thanks anyblody for anyhelp!)
Weird issue (?) with form validation/submit
Hi, I have a form on my page, which I want to validate on submit. The code looks something like this: $('#form').submit(function(){ if ($('#field1').length == 4 && $('#field2').length == 3) { $.ajax({ url: someAjaxUrl, dataType: 'html', type: 'get', success: function(html){ if (html != '') { //show error } else { //submit form }
Fade in/Fade out poor rendering across browsers
Hi. I'm having problems with my text appearing aliased and turning blue when it fades in and out. I've tried using the Newsticker plugin and the Easyticker plugin, and I'm getting the same result in IE7 and Firefox 3.6. I'm using jQuery 1.2.6-min Any idea what might be causing this? The examples on the plugin websites look fine, but when I try and implement the effect myself, my orange text becomes aliased and fades to a light blue color before dipping to white. Same thing happens on the fade
How to POST using .load() ? - works in IE and Safari not in Firefox
The documentation for .load() and .get() says that if a map (JSON object) is passed, the request will be treated as a POST not a GET. This is what I have done in my code below. It works in IE and Safari but not in Firefox: var dataJSON = {}; // Scrape text input field names and corresponding values into the JSON object $("#MyForm input:text").each(function(index, element){ dataJSON[$(element).attr("name")] = $(element).val(); }); $("#Results_Container").load( "/Product_Registration.html #Results",
validation errors
Hi all, Using the validation plugin and it works great except for one little problem. On a text box, if the field does not pass validation then the error will display directly to the left, as expected. However, if the input of the field is deleted and the required rule is tripped, then the error message is overlaid on the text box. Looking at the source in firebug, I noticed that the error style is set to display: block in the latter case, but at no other time. Is there a setting or attribute I
Proper way to send multiple checkbox values through a .get?
I have checkbox inputs like so: <input type="submit" value="One" id="one" /> <input type="submit" value="Two" id="two" /> Say they are both checked.. How would I send those values through the code below properly? $('#submit').click(function(){ value = $('input:checked'); // not sure how to collect all checkbox values here so they can be sent.. $.get('/file.php', { action: 'update', value: value }, function (html) { $("#display").html(html); }); });
Form Validation Error
Hi all, I have ran into an error that I can't figure out how to fix. It's with the updateTips function on line 14 and the error is: tips.text(t).effect is not a function. This happens when I hit submit on the form. Ah here is my code: <script type="text/javascript"> $(document).ready(function() { var $loading = $('<img src="loading.gif" alt="loading" class="loading">'); var name = $("#name"), shortname = $("#shortname"), cname = $("#cname"),
Convert Element ID to String
$(document).ready ( function() { $("#stepBox li").hover ( function() { var elid = $(this).attr('id'); loadSWF("/ovi/lib/swfs/"+elid+".swf", "flashBox"); } ); } ); I need a way to convert the ID on line 9 into a string which can be used as a variable on line 10. Is this possible? An example would be greatly appreciated. (P.S. I'm truly sorry if this ends up as a double-post. My browser froze up
How to wrap elements from an external JS file into a function then call that function?
Hello, I was wondering how I can accomplish wrapping relevant parts of a script into a function then call that function within a success area on another page. This is what I have so far: Script.js page - This page is longer but this is the relevant part that I would like to wrap: $(".product img").draggable({ containment: 'document', opacity: 0.6, revert: 'invalid', helper: 'clone', zIndex: 100 }); $("div.content.drop-here").droppable({ drop: function(e, ui) { var param = $(ui.draggable).attr('src');
datafilter set by ajaxSettings is not being called when using jqGrid
Hi, I'm not entirely sure whether this is a jQuery issue or a jqGrid issue, but we are using the jqGrid to display our grids, and easily enable sorting and filtering. THis works great. Our server howvever is designed to wrap ALL result into an array of generic information that should always be returned to the client (such as fields we want to keep up to date, status of the server, or just error messages), and put the actual data to be turned into the $array["data"] prior to json_encode it and sending
Can't parse valid JSON
ccording to JSONLint (http://www.jsonlint.com/) my JSON is valid. This is what I do: (I use a cross-domain-plugin to allow external ajax requests) $.ajax({ url: "[url]http://jquery-old-browser-warning.googlecode.com/files/languages.json[/url]", type: "GET", dataType: "text", async: false, success: function(res) { var x = $("" + res.responseText + ""); //Cleaning up the response from Google Code. var json = x[5].innerHTML; //Alerting this gets me the correct node with my JSON var jsonData = jQuery.parseJSON(json);
Jquery cannot do a sliding panel with collapse ? Is there a solution for this out there?
I look for something in jquery ( a sliding panel div that can also be collapsed and shows the correct image, hard to explain please see below link, its used on this page: http://www.sigmawidgets.com/products/sigma_visual/Samples/comb/OutLoo... The sliding panel with the |> <| marker displayed when its open or closed.. Anything such exist for jquery with the same features?
val() gets the default value even if another value is filled
Hi, I have a form with a input text field, a link, when I click the link gets the value of the field, but as the field has a default value it gets that even if the user fills something else. I get the value like this: $("#input_email").val() and the field looks like: <input name="email" id="input_email" type="text" class="txtField01" value="Email Address" /> It works only if I refresh the page first, and that is not nice :) Can someone help?
:not selector in IE doesn't work
Hi, I have a few <div class="c"></div> I do $(".c:not(:last)").css({borderColor:"#0f0"}) This is OK in Firefox, but in IE all columns get this color. The :not selector doesn't work in IE. Why not?
jquery add li to end of ul but last created li not recognised as last
I have the following code. On cliking the button on the last li, I can create the new li. However, once created, if I click on the latest button created, new li is created. It seems it doesn`t recognise the last created li as the last li. Can someone help on this please <div> <ul id="mylist"> <li id="1">1<button id="Button3">Delete</button> </li> <li id="2">2<button id="Button2">Delete</button></li> <li id="3">3<button id="another_entry">Save</button></li> </ul> <ul id="mylist2">
jcarousel and lightbox? Slider for portfolio
Just wondering if it is possible to have like a slider going from side to side of an image or multiple images with a description and when the image is clicked on it opens the lightbox of a larger image? Would this be possible with jcarousel and lightbox? Or anything else? I am required to do this for work and have done basic stuff with jquery using the easylider etc but im stuck on this! I have found an example of something what we need here > http://jonraasch.com/portfolio Any pointers or help would
Bug with do{}while
maybe anyone can tell is this an error or i'm doing something wrong. as i understand there must value 123 in the #footer div, but i get 444 (this div is made just to see the values of var "w" at all stages, all i need is string 6 in my code) ct_all=3 w=1 do{ toto='#center_' + w $.get("include/view_function.php", { hot: w},function(data){$(toto).load(data + " .tp_offers_tbl"); $('#footer').append(w) }); w++ }while(w<=ct_all)Thanks anyblody for anyhelp!)
Next Page