Search Results

Search found 23820 results on 953 pages for 'jquery ui autocomplete'.

Page 122/953 | < Previous Page | 118 119 120 121 122 123 124 125 126 127 128 129  | Next Page >

  • JQuery - Fade in new Background Image?

    - by JasonS
    Hi, I think I may be trying something that isn't possible. I was recently tasked to create a html version of the flash site. On the flash site when you click on the body the image changes. I have done this with JQuery. Its brilliant! However.. it isn't "flash" enough. The powers that be want a fade effect between images. This is where I have come completely undone. This is how my script works at the moment. Images are stored in a div called photos. This is hidden. <div id="photos"> <img src="image.jpg" alt="Some caption" style="#page-bg-color" /> </div> When the page is loaded jquery checks to see if the first image is loaded. If it isn't then a loading symbol spins. When the image is loaded, it becomes the body background. $("body").css('background', 'url(' + photos[currentImage]["url"] + ') no-repeat 50% 50% fixed ' + photos[currentImage]["background"]); I have tried the following. I have tried animate. However, this doesn't work. I have tried this plugin: http://plugins.jquery.com/project/bgImageTransition This doesn't work either. It appears to clone the tag and do something. I assume it isn't working because you cannot clone the body tag. That or it is really old and is no longer compatible with the current version of JQuery. I fear that I have coded my way down a dead end. Does anybody know how I could make this work?

    Read the article

  • jQuery AJAX Loading Page Content Only After I Press Shift Key

    - by Cosmin
    My ajax + jquery loading page only after holding shift key and duplicate new empty window. If I press the loading button nothing hapen, only after I press shift key I get to load the page correctly... this is my ajax script: $(document).ready(function () { $(".getUsersA").click(function () { $.ajax({ beforeSend: function () { $(".gridD").html(spinner) }, url: 'lib/some_url.php', type: 'POST', data: ({ data1:'2013-09-01' }), success: function (results) {$(".gridD").html(results);} }); }); }); I have a second js file with just this line of code for spinner var spinner = "<img src='images/spinner.gif' border='0'>"; html code: <html> <head> <title>Title</title> <script type="text/javascript" src="js/jquery-1.10.2.js"></script> <script type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript" src="js/general.js"></script> </head> <body> <h1>Putting it all tugether ... with jQuery</h1> <div class="thedivD"><a href="" class="buttonA getUsersA">Get Users</a></div> <h3>jQuery results</h3> <div class="gridD"></div> </body> </html>

    Read the article

  • Multiple forms using Rails & jQuery & AJAX

    - by biggie8199
    I have multiple coupons on a page and I'm trying to get comments to work on each coupon. So for each coupon i have a comments form. Im using jQuery + Ajax to accomplish this. Here's what my code looks like. Coupon Page <p>Comments:</p> <% form_for(@comment) do |f| %> <%= f.label :body %><br /><%= f.text_field :body, :size => "24" %> <%= f.hidden_field :coupon_id, :value => coupon.id %> <%= f.submit "Save" %> <% end %> Application.js jQuery.ajaxSetup({ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} }) jQuery.fn.submitWithAjax = function() { this.submit(function() { $.post(this.action, $(this).serialize(), null, "script"); return false; }) return this; }; $(document).ready(function() { $("#new_comment").submitWithAjax(); }) I tried changing the jQuery selector to a class $(".new_comment").submitWithAjax(); Thinking that would work, now all the submit buttons work, however it posts only the first form on the page. What can I change to make it so ajax submits the correct form and not the first one?

    Read the article

  • Problem with jQuery slider - time

    - by Dawid
    Hello. I'd like to make a slider to choose time(from 1:00 to 4:00) but it doesn't work. It doesn't communicate with 'select'. Can anyone help me? <script> $(function() { var select = $( "#czastrwania" ); var slider = $( "<div id='slider'></div>" ).insertAfter( select ).slider({ min: 60, max: 240, step: 30, range: "min", value: select[ 0 ].selectedIndex + 1, slide: function( e, ui ) { var hours = Math.floor(ui.value / 60); var minutes = ui.value - (hours * 60); if(hours.length == 1) hours = '0' + hours; if(minutes.length == 1) minutes = '0' + minutes; select[ 0 ].selectedIndex = ui.value - 1; } }); $( "#czastrwania" ).change(function() { slider.slider( "value", this.selectedIndex + 1 ); }); }); </script> <select id="czastrwania" name="czastrwania"> <option value="1:00">1:00</option> <option value="1:30">1:30</option> <option value="2:00">2:00</option> <option value="2:30">2:30</option> <option value="3:00">3:00</option> <option value="3:30">3:30</option> <option value="4:00">4:00</option> </select>

    Read the article

  • Calling jQuery method from onClick attribute in HTML

    - by Russell
    I am relatively new to implementing JQuery throughout an entire system, and I am enjoying the opportunity. I have come across one issue I would love to find the correct resolve for. Here is a simple case example of what I want to do: I have a button on a page, and on the click event I want to call a jquery function I have defined. Here is the code I have used to define my method (Page.js): (function($) { $.fn.MessageBox = function(msg) { alert(msg); }; }); And here is my HTML page: <HTML> <head> <script type="text/javascript" src="C:\Sandpit\jQueryTest\jquery-1.3.2.js"></script> <script language="javascript" src="Page.js"></script> </head> <body> <div class="Title">Welcome!</div> <input type="button" value="ahaha" onclick="$().MessageBox('msg');" /> </body> </HTML> (The above code displays the button, but clicking does nothing.) I am aware I could add the click event in the document ready event, however it seems more maintainable to put events in the HTML element instead. However I have not found a way to do this. Is there a way to call a jquery function on a button element (or any input element)? Or is there a better way to do this? Thanks

    Read the article

  • create jquery array to use as options

    - by SoulieBaby
    Hi all, I'm sure this is really simple, but I can't seem to get it working. I have a "time" select list, which has a number as "rel" attached to each option. If the user changes the time select, I want a new list of options to display depending on what is selected. If that makes sense? Here's my first select: <select name="time" id="time"> <option value="7:00am" rel="10">7:00am</option> <option value="12:30pm" rel="16">12:30pm</option> </select> If the user selects 7:00am, I want a new option list (using jquery) to give options from 1 - 10. Like this: <select name="quantity" id="quantity"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> ............................ <option value="10">10</option> </select> Here's what I have so far... <script type="text/javascript" language="javascript"> jQuery("#time").change(function(){ var positions = jQuery("#time :selected").attr("rel"); //this grabs the rel from time //this is where it should create a list of options to append(??) to the select list.. jQuery("#showQuantity").show(); //this shows the hidden field for quantity }); </script> I hope it makes sense, but I'm stuck on it. Thank you in advance :)

    Read the article

  • Making a jQuery plugin to feed Tumblr to site

    - by tylorreimer
    I have some experience with PHP and a little with JS but I'm far from anything proficient. I'm trying to make a jQuery plugin for my site that I can call in my HTML via something like this: $('.new').tumble({username: "tylor", count: 9}); Which would basically put the Tumblr list the code should make into the DIV with class 'new' in this case. Here is my code so far; the problem seems to be how to get it to pick up class/id from the original call (in the HTML) and use that in the jQuery. Here's the code so far: (function($) { $.fn.tumble = function(options){ var settings = $.extend({ username: null, // [string or array] required to get url for tumblr account count: 3, // [integer] how many posts to display? }, options); //url construction var url = "http://" + settings.username + ".tumblr.com"; var jsonurl = url + "/api/read/json?num=" + settings.count + "&callback=?"; $.getJSON(jsonurl, function(data) { var items = []; $.each(data.posts, function(id, url) { // Goes over each post in the JSON document retrieved from data URL var url = this.url; // Just assigns a variable to the url to avoid constantly writing "this.whatever" var photourl = this['photo-url-250']; // photo-url-xxx needs to be called this way due to integers in the name items.push('<li><a href="' + url + '">' + photourl + '</a></li>'); }); $('<ul/>', { // Creates an empty list html: items.join('') // Takes the values in the item array and puts 'em together }).appendTo('.new'); // I don't want this to have the class set in the jQuery itself }); //end json }; })( jQuery ); Any help you can lend would be wonderful. Thank you

    Read the article

  • jquery draggable/droppable issue

    - by Scarface
    Hey guys I have a drag and drop function that does not fully work. What I want to do is be able to drag and drop a picture into a div and have that picture pop up in the div. I have a list of 2 pictures right now, so I have the following function echoed for each picture. Both pictures are draggable and droppable, but the first one is the only one that appears in the div, regardless of which picture gets dragged in. I am not sure what is wrong because the jquery function seems to be unique to each picture. If any one has any suggestions I would appreciate it greatly. while ($row = mysql_fetch_assoc($query)) { $image=htmlentities($row['image']); //image name $uniqid=uniqid(); //unique id for jquery functions $dirname = "usercontent/$user/images/$image"; echo "<img id=\"$uniqid\" src=\"$dirname\" width=\"75\" height=\"75\"/>"; echo "<script> $(function() { $(\"#$uniqid\").draggable({ scroll: true, scrollSensitivity: 10, scrollSpeed: 10, revert: true, helper: 'clone', cursorAt: { cursor: 'move', top: 27, left: 27 } }); $(\"#droppable2, #droppable-background , #droppable2-innerer\").droppable({ greedy: true, activeClass: 'ui-state-hover', hoverClass: 'ui-state-active', drop: function(event, ui) { $(this).addClass('ui-state-highlight').find('> p').html('Dropped!'); $('#droppable-background').css(\"background-image\",\"url($dirname)\"); } }); }); </script>"; }

    Read the article

  • jQuery: Stopping a periodic ajax call?

    - by Legend
    I am writing a small jQuery plugin to update a set of Divs with content obtained using Ajax calls. Initially, let's assume we have 4 divs. I am doing something like this: (function($) { .... .... //main function $.fn.jDIV = { init: function() { ... ... for(var i = 0; i < numDivs; i++) { this.query(i); } this.handlers(); }, query: function(divNum) { //Makes the relevant ajax call }, handlers: function() { for(var i = 0; i < numDivs; i++) { setInterval("$.fn.jDIV.query(" + i + ")", 5000); } } }; })(jQuery); I would like to be able to enable and disable a particular ajax query. I was thinking of adding a "start" and "stop" instead of the "handlers" function and subsequently storing the setInterval handler like this: start: function(divNum) { divs[divNum] = setInterval("$.fn.jDIV.query(" + i + ")", 5000); }, stop: function(divNum) { clearInterval(divs[divNum]); } I did not use jQuery to setup and destroy the event handlers. Is there a better approach (perhaps using more of jQuery) to achieve this?

    Read the article

  • Confirm box always displays first (javascript, jQuery, .Net)

    - by Jan-Frederik Carl
    Hello, I have a jQuery-Script to accomplish the following tasks: if a gridview in my form contains a row with a certain id, it has to be marked red. a confirm dialogue has to pop up to ask the user if he wants to do this or that. I built this code: if (response == "EntryInList") { $('#entryListContainer div table tbody tr').each(function() { if ($(this).attr('id') == 'entry_' + $('#<%= txtProductNumber.ClientID %>').val()) { $(this).css("color", "red"); } } ); if (!confirm("Entry already exists. Really overwrite?")) { jQuery('#<%= txtProductNumber.ClientID %>').val(''); jQuery('#<%= txtCount.ClientID %>').val(''); jQuery('#<%= txtProductNumber.ClientID %>').focus(); return false; } } As a result, the confirm box pops up first, without the row being turned red. Only after using the box, it becomes red. How would I get the row to be turned red at once? Another of my problems is that the confirm box denies my page to be scrolled down. But I would like to do this if the gridview is longer than the entire page.

    Read the article

  • Accessing jQuery objects in the module pattern

    - by Stewart
    Hello, Really getting in to javascript and looking around at some patterns. One I have come accross is the module pattern. Its seems like a nice way to think of chucks of functionality so I went ahead and tried to implement it with jQuery. I ran in to a snag though. Consider the following code <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>index</title> <script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var TestClass2 = (function(){ var someDiv; return { thisTest: function () { someDiv = document.createElement("div"); $(someDiv).append("#index"); $(someDiv).html("hello"); $(someDiv).addClass("test_class"); } } })(); TestClass2.thisTest(); }); </script> </head> <body id="index" onload=""> <div id="name"> this is content </div> </body> </html> The above code alerts the html content of the div and then adds a class. These both use jQuery methods. The problem is that the .html() method works fine however i can not add the class. No errors result and the class does not get added. What is happening here? Why is the class not getting added to the div?

    Read the article

  • jquery getjson works fine in mac, and fails in windows

    - by viper
    this code loads the data jQuery.ajax({ type: "GET", url: "getOptionsJson.php", cache: false, dataType: "json", data: "config_id="+config_id, success: function(json) { jQuery.extend(dataArr, json.ajax); jQuery.extend(opts, json.ajax2); printResult(config_id); }, error: function() { alert('Error. Please try again'); location.reload(); } }); this code generates it <?php header('Content-type: application/javascript'); echo json_encode(array( "ajax" => array(1 => "test", 2 => "test 2"), "ajax2" => array(1 => "test 3", 2 => "test 4") ); ?> when im working on mac, everything goes fine, but today i tried it on widnows, and it doesnt work. the code flows like its success, but opts and dataArr are null i tried all headers (application/json, text/html, etc) i checked if getOptionsJson.php is called correctly via mail function filnally firebug says that im getting response, but theres no content and file is just 1kb i tried even changing datatype to xml, still fails ie gives a hint, it says 'there's error on site' which reffers to 127 line of jquery file any idea?

    Read the article

  • Javascript and jQuery (Fancybox) question

    - by songdogtech
    Javascript and jQuery (Fancybox) question I'm using the Javascript function below for Twitter sharing (as well as other services; the function code is simplified to just Twitter for this question) that grabs the to-be-shared page URL and title and it is invoked in the link with onclick. That results in the Twitter share page loading in a pop up browser window, i.e.<img src="/images/twitter_16.png" onclick="share.tw()" /> In order to be consistent with other design aspects of the site, what I'd like to be able to do is have the Twitter share page open not in a standard browser window but in a Fancybox (jQuery) window. Fancybox can load an external page in an iFrame when the img or href link contains a class (in this case class="iframe" ) in the link and in the document ready function in the header. Right now, of course, when I give the iframe class to the link that also has the onclick share.tw(), I get two popups: one browser window popup with the correct Twitter share page loaded, and a Fancybox jQuery popup that shows a site 404. How can I change the function to use Fancybox to present the Twitter share page? Is that a correct way to approach it? Or is there a better way, such as implementing the share function in jQuery, too? Thanks... Javascript share function: var share = { tw:function(title,url) { this.share('http://twitter.com/home?status=##URL##+##TITLE##',title,url); }, share:function(tpl,title,url) { if(!url) url = encodeURIComponent(window.location); if(!title) title = encodeURIComponent(document.title); tpl = tpl.replace("##URL##",url); tpl = tpl.replace("##TITLE##",title); window.open(tpl,"sharewindow"+tpl.substr(6,15),"width=640,height=480"); } }; It is invoked, i.e.: <img src="/images/twitter_16.png" onclick="share.tw()" /> Fancybox function, invoked by adding class="iframe" in the img or href link $(".iframe").fancybox({ 'width' : '100%', 'height' : '100%', 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe' });

    Read the article

  • jQuery + External javascript: How to embed videoplayer in div

    - by Dennis
    I just started with jQuery and so far I have a really good impression of the framework. But now I have a problem that I can't figure out on myself. I want to embed an external javascript file that loads a videoplayer and displays it. If I include the <script>...</script> directly in HTML it loads just fine. But when I try to load it with jQuery it has very different behaviors in several browsers but it doesn't work in a single one. Either the player is not loaded at all or it doesn't update the selected div but reloads the player on a blank page. This is the source: <html> <head> <style type="text/css"> div#test { width: 100%; height: 500px; margin: 10px auto; padding: 5px; border: 1px solid #777; background-color: #fbca93; text-align: center; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ var video = "<script type=\'text\/javascript\' src=\'http:\/\/www.physicalfitnet.com\/video_syndication\/embed\/jssingle.aspx?vid=651&pub=9DF8233261D101B86368400385B8FF2E\'><\/script>"; $("div#test").html(video); }); </script> </head> <body> <div id="test"> Hi</div> </body> </html> I uploaded everything to http://kernast.de/test ... any help is appreciated. THX

    Read the article

  • jQuery: If, Else with buttons error

    - by Wipqozn
    I'm running into an odd error. I'm working in Django 1.2, and have implemented the commenting framework. I'm trying to attach a hide/show button to each comment field, but whenever click on a hide/show button, it behaves as if each hide/show button beneath it on the page was clicked. Here's the jQuery code: <input type="Button" id="hideShow" name="hide/show" value="Hide"></input> <script> $("#hideShow").click(function() { if($(this).val() == "Hide") { $("textarea").hide("fast"); $(this).val("Show"); } else { $("textarea").show("fast"); $(this).val( "Hide"); } }); </script> So, when I click the Hide/show button, it will perform the action for each button beneath the clicked button + once for the button itself. So If I click a button, and there are two buttons beneath it, and value=hide it will first hide the 'textarea', than show the text area, than finally hide it again. I'm new to jQuery (although I do have experience in other languages), and I have an -idea- why it's not working: that whenever an action is performed jQuery jumps to the first one, than continues down the page looking for any other actions performed, and responds to each one. So it comes to my first button, sets it as being clicked, and so when jQuery comes across the other buttons it views them all as being 'clicked' and performs actions accordingly. I've thought of a semi-solution to my problem, putting in a variable which tracks how many times it has gone through, and than acting based on -that- action. But I would rather not do that, since it's not really a solution to the problem at hand but a work around. Any input is appreciated.

    Read the article

  • How to create Hash object/array using jquery?

    - by Patrick
    Hi folks I know there is a Hash() object in the Javascript prototype framework, but is there anything in Jquery like this? As I would like to stick with one javascript framework, rather than mixing the Prototype Frame work and the JQuery framework and use at the same time, as I worry there will be conflict and create side-effects. So my question is: how to create Hash object/array using jquery? Here is my function: /* prototype framework, I want to change this to jQuery! */ var starSaves = new Hash(); function myHover(id, pos) { var starStrip = $('star_strip_' + id); if (starSaves.keys().indexOf(id) == -1) { var starSave = new Array(); var imgs = starStrip.select("img") alert(imgs); for (var i = 0; i < imgs.length; i++) { starSave[starSave.length] = imgs[i].src; if (i < pos) imgs[i].src = "/images/star_1.gif"; else imgs[i].src = "/images/star_0.gif"; } starSaves.set(id, starSave); } }

    Read the article

  • How can I design a custom control in Javascript (possibly using jQuery)

    - by Mathieu Pagé
    I'd like to create a custom control in javascript. The goal is to create a building block that has methods, properties and events and render into a div. An example of one such control would be a calendar. It would render into a div, it would have properties that would define how it's displayed and what date is selected or highlighted, it would have methods to change the current month or to select some date and it would raise events when a day is clicked or the current month is changed by a user input. I can think of lots of way to implement this and I'm not sure what is the best way. I seem to remember that it's a bad thing to augment a DOM elements with properties and method, so I ruled that out. A jQuery plugin seems like a good idea, however I'm not sure if it's appropriate to create a plugin for each and every method my control would have so I could then use it like : $('#control').method1(); $('#control').method2(); And if I do use jQuery, where do I store the private data of my control? Another idea I got was to create a new kind of object that would have a reference to a div in which it could render it's elements. So what is the prefered way to do this. If I can I would like to do this as a jQuery plugin, but I'd need guidlines on how to create methods and where to store private data. I've loked at Plugins/Authoring on jQuery website and it did not helped that much in this regard.

    Read the article

  • Can JQuery.Validate plugin prevent submission of an Ajax form

    - by berko
    I am using the JQuery form plugin (http://malsup.com/jquery/form/) to handle the ajax submission of a form. I also have JQuery.Validate (http://docs.jquery.com/Plugins/Validation) plugged in for my client side validation. What I am seeing is that the validation fails when I expect it to however it does not stop the form from submitting. When I was using a traditional form (i.e. non-ajax) the validation failing prevented the form for submitting at all.... which is my desired behaviour. I know that the validation is hooked up correctly as the validation messages still appear after the ajax submit has happened. So what I am I missing that is preventing my desired behaviour? Sample code below.... <form id="searchForm" method="post" action="/User/GetDetails"> <input id="username" name="username" type="text" value="user.name" /> <input id="submit" name="submit" type="submit" value="Search" /> </form> <div id="detailsView"> </div> <script type="text/javascript"> var options = { target: '#detailsView' }; $('#searchForm').ajaxForm(options); $('#searchForm').validate({ rules: { username: {required:true}}, messages: { username: {required:"Username is a required field."}} }); </script>

    Read the article

  • IIS6 throws error for jquery.

    - by user309557
    Hi, on my master page, I have referenced jquery file. I am doing simple hover function. When mouse hover, I change the css and when hover out, change the css back to originial. Nothing fancy. but my page throws jquery error when I run in IIS6 on server 2003. When I run on IIS5.1 on local xp machine, it works perfectly fine. Any idea? I access both pages from my machine so IE settings is not the problem. I opened the both js file and the error line is nothing but the end of the file ( i.e last line of the js file) Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.4; OfficeLivePatch.1.3) Timestamp: Mon, 5 Apr 2010 21:59:18 UTC Message: Syntax error Line: 4377 Char: 2 Code: 0 URI: server-test/myapplication/Scripts/jquery-1.3.2.js (removed the link because stackoverflow does not allow me to put more than one link) Message: Syntax error Line: 6183 Char: 2 Code: 0 URI: server-test/myapplication/Scripts/jquery-1.3.2-vsdoc.js (removed the link because stackoverflow does not allow me to put more than one link) Message: Object expected Line: 189 Char: 9 Code: 0 URI: http://server-test/myapplication/

    Read the article

  • How do I use jQuery in my Greasemonkey Javascript scripts?

    - by tladuke
    I saw a question here and many blog posts about getting jquery into greasemonkey, but I can't get anything to work. Here's my script: // ==UserScript== // @name Hello jQuery // @namespace http://foo.bar // @description jQuery test script // @include * // ==/UserScript== #{contents of jquery.latest.js pasted in} unsafeWindow.jQuery = jQuery; $(document).ready(function() { alert('Hello world!'); }); I'm hoping to see an alert when I refresh a page, so I can start actually programming something. I've tried a bunch of other things and so far nothing works. The script is enabled in the little monkey menu... edit: the script part now looks like this: foo(); function foo() { $ = unsafeWindow.jQuery; $('tr td.row2:nth-child(4)').css("background-color", "#999"); } it doesn't work. I know the jQuery is good because I can run it from outside of greasemonkey. If instead of a jQuery function is just say alert('hello'); that works fine; I get the alert on page-load.

    Read the article

  • jquery an div tags used in a ordered list

    - by shan2on
    hello everyone, i'm not sure where my errors are lying but here is my scenario... i have an un-ordered list in html that handles my main link bar... <ul id="navlist"> <li><a href="/" id="current">home</a></li> <li><a href="#" id="search">search</a></li> <li><a href="#" id="users">login</a></li> </ul> and what i want done is to call each id and have jQuery handle each and dislpay it where specified in my css file... for now, lets just ignore my "home" link... here is a snippet of my inline jquery $(document).ready(function() { $("a").click(function () { $("div#login").slideToggle("fast"); }); }) Now, whichever div i specify, it calls that ... however it will only call one div, using either from the un-orderd list, as mentioned above in the html. My Goal is to call a search bar when search is clicked, and to call a login box when login is clicked. to my knowledge (noob), i believe use an as a class, however that is what brings me here. i believe my error is in my jquery and not my css, as stated above, either instance will be displayed when the jquery function calls either tag. any help is greatly appreciated. thanks in advance shan2on

    Read the article

  • jQuery: responding to click event of element added to document after page load

    - by morpheous
    I am writing a page which uses a lot of in situ editing and updating using jQuery for AJAX. I have come accross a problem which can best be summarised by the workflow described below: Clicking on 'element1' on the page results in a jQuery AJAX POST Data is received in json format The data received in json format The received data is used to update an existing element 'results' in the page The received data is actual an HTML form I want jQuery to be responsible for POSTing the form when the form button is clicked The problem arises at point 6 above. I have code in my main page which looks like this: $(document).ready(function(){ $('img#inserted_form_btn').click(function(){ $.ajax({'type: 'POST', 'url': 'www.example.com', function($data){ $(data.id).html($data.frm); }), 'dataType': 'json'} }); }); However, the event is not being triggered. I think this is because when the document is first loaded, the img#inserted_form_btn element does not exist on the page (it is inserted into the DOM as the result of an element being clicked on the page (not shown in the code above - to keep the question short) My question therefore is: how can I get jQuery to be able to respond to events occuring in elements that were added to the DOM AFTER the page has loaded?

    Read the article

  • Problem with mathamatical calculation in JQUERY

    - by Param-Ganak
    Hello friends! I have two text boxes. I enter number in one textbox. I write following JQUERY for that textbox which get executed when the focus out from first text box. The JQUERY code takes the entered value from first text box and multiply it by a decimal number 34.95 and display the answer in second text box. The code is doing the calculation little bit ok because when I enter the value 1000 in first text box it gives answer 34950 in second textbox and when I enter the value 100 in first text box it gives answer 3495.0000000000005 in second text box. **Please any one tell me what is the problem. is problem is in my JQUERY code. I also want to show the answer always in decimal point. Answer should always dislply only two digits after decimal point. so How to achieve this too.** This is my JQUERY code. $("#id_pvalue").focusout(function() { q=$("#id_pvalue").val(); var ans=q*34.95; $("#id_tvalue").val(ans); }); Please guide me friends! Thank You!

    Read the article

  • jquery tabs - load url in current tab?

    - by BigDogsBarking
    I'm trying to figure out how to load the url each tab links to inside the tab area onclick, and have been trying to following the docs at http://docs.jquery.com/UI/Tabs#...open_links_in_the_current_tab_instead_of_leaving_the_page, but am clearly not getting it.... This is the HTML markup: <div class="tabs"> <ul class="tabNav"> <li><a href="/1.html#tabone">Tab One</a></li> <li><a href="/2.html#tabtwo">Tab Two</a></li> <li><a href="/3.html#tabthree">Tab Three</a></li> </ul> </div> <div id="tabone"> <!-- Trying to load content from 1.html in this div on click --> </div> <div id="tabtwo"> <!-- Trying to load content from 2.html in this div on click --> </div> <div id="tabthree"> <!-- Trying to load content from 3.html in this div on click --> </div> And this is the jquery I'm trying to use: $(".tabs").tabs({ load: function(event, ui) { $('a', ui.panel).click(function() { $(ui.panel).load(this.href); return false; }); } }); I know I've got some part of this wrong.... I've gone through several iterations (too many to post), and all I get is a blank div... I don't know... Feeling a bit confused here... Help?

    Read the article

  • Getting Response From Jquery JSON

    - by Howdy_McGee
    I'm having trouble getting a response from my php jquery / json / ajax. I keep combining all these different tutorials together but I still can't seem to pull it all together since no one tutorial follow what I'm trying to do. Right now I'm trying to pass two arrays (since there's no easy way to pass associative arrays) to my jquery ajax function and just alert it out. Here's my code: PHP $names = array('john doe', 'jane doe'); $ids = array('123', '223'); $data['names'] = $names; $data['ids'] = $ids; echo json_encode($data); Jquery function getList(){ $.ajax({ type: "GET", url: 'test.php', data: "", complete: function(data){ var test = jQuery.parseJSON(data); alert(test.names[0]); alert("here"); } }, "json"); } getList(); In my html file all I'm really calling is my javascript file for debugging purposes. I know i'm returning an object but I'm getting an error with null values in my names section, and i'm not sure why. What am I missing? My PHP file returns {"names":["john doe","jane doe"],"ids":["123","223"]} It seems to be just ending here Uncaught TypeError: Cannot read property '0' of undefined so my sub0 is killing me.

    Read the article

< Previous Page | 118 119 120 121 122 123 124 125 126 127 128 129  | Next Page >