Search Results

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

Page 2/953 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • jQuery autocomplete not always working on elements

    - by PoweRoy
    I'm trying to create a greasemonkey script (for Opera) to add autocomplete to input elements found on a webpage but it's not completely working. I first got the autocomplete plugin working: // ==UserScript== // @name autocomplete // @description autocomplete // @include * // ==/UserScript== // Add jQuery var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; GM_JQ.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(GM_JQ); var GM_CSS = document.createElement('link'); GM_CSS.rel = 'stylesheet'; GM_CSS.href = 'http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css'; document.getElementsByTagName('head')[0].appendChild(GM_CSS); var GM_JQ_autocomplete = document.createElement('script'); GM_JQ_autocomplete.type = 'text/javascript'; GM_JQ_autocomplete.src = 'http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js'; document.getElementsByTagName('head')[0].appendChild(GM_JQ_autocomplete); // Check if jQuery's loaded function GM_wait() { if(typeof window.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } else { $ = window.jQuery; letsJQuery(); } } GM_wait(); function letsJQuery() { $("input[type='text']").each(function(index) { $(this).val("test autocomplete"); }); $("input[type='text']").autocomplete("http://mysite/jquery_autocomplete.php", { dataType: 'jsonp', parse: function(data) { var rows = new Array(); for(var i=0; i<data.length; i++){ rows[i] = { data:data[i], value:data[i], result:data[i] }; } return rows; }, formatItem: function(row, position, length) { return row; }, }); } I see the 'test autocomplete' but using the Opera debugger(firefly) I don't see any communication to my php page. (yes mysite is fictional, but it works here) Trying it on my own page: <body> no autocomplete: <input type="text" name="q1" id="script_1"><br> autocomplete on: <input type="text" name="q2" id="script_2" autocomplete="on"><br> autocomplete off: <input type="text" name="q3" id="script_3" autocomplete="off"><br> autocomplete off: <input type="text" name="q4" id="script_4" autocomplete="off"><br> </body> This works, but when trying on another pages it sometimes won't: e.g. http://spitsnieuws.nl/ works but http://nu.nl and http://dumpert.nl don't work. Trying the autocomplete of jquery ui has more problems: // ==UserScript== // @name autocomplete // @description autocomplete // @include * // ==/UserScript== // Add jQuery var GM_JQ = document.createElement('script'); GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'; GM_JQ.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(GM_JQ); var GM_CSS = document.createElement('link'); GM_CSS.rel = 'stylesheet'; GM_CSS.href = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css'; document.getElementsByTagName('head')[0].appendChild(GM_CSS); var GM_JQ_autocomplete = document.createElement('script'); GM_JQ_autocomplete.type = 'text/javascript'; GM_JQ_autocomplete.src = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js'; document.getElementsByTagName('head')[0].appendChild(GM_JQ_autocomplete); // Check if jQuery's loaded function GM_wait() { if(typeof window.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } else { $ = window.jQuery; letsJQuery(); } } GM_wait(); // All your GM code must be inside this function function letsJQuery() { $("input[type='text']").each(function(index) { $(this).val("test autocomplete"); }); $("input[type='text']").autocomplete({ source: function(request, response) { $.ajax({ url: "http://mysite/jquery_autocomplete.php", dataType: "jsonp", success: function(data) { response($.map(data, function(item) { return { label: item, value: item } })) } }) } }); } This will work on my html page, http://spitsnieuws.nl and http://dumpert.nl but not on http://nu.nl. (dumpert didn't work on the plugin autocomplete) //http://spitsnieuws.nl <input class="frmtxt ac_input" type="text" id="zktxt" name="query" autocomplete="off"> //http://dumpert.nl <input type="text" name="srchtxt" id="srchtxt"> //http://nu.nl <input id="zoekfield" name="q" type="text" value="Zoek nieuws" onfocus="this.select()" type="text"> Anyone know why the autocomplete functionality doesn't work? Why the request to the php page is not being made? And why I can't add my autocomplete to google.com?

    Read the article

  • jquery autocomplete IE 9 not working

    - by Al3mor
    I am trying to autocomplete in a input, It is working fine in Chrome,Safari&Firefox . It is not working on IE 9 alone. Please help. $("#name").autocomplete({ select: function(event, iu) { id = event.toElement.innerText.split('-') $("#id_estudiante").val(id[1]); $("#FinancieroGrid").load('php/Financiero/librerias/FindStudent.php?action='+id[1].replace(' ','')); }, source:'php/Financiero/function/getstuden.php', minLength:1 });

    Read the article

  • jquery mouseover/mouseout

    - by Hulk
    In the following code once the mouse out is done the mouse over again does not work ,what is the work around for this <!DOCTYPE html> <html> <head> <style> /* div { background:#def3ca; margin:3px; width:80px; display:none; float:left; text-align:center; }*/ </style> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> <body> <div id="playControls" style="position:absolute; bottom:0px; left:0px; right:0px;color:blue;"> Mouse over me </div> <script> $(document).ready(function() { $("#playControls").mouseover(function () { alert('here'); $("div:eq(0)").show("fast", function () { /* use callee so don't have to name the function */ $(this).next("div").show("fast", arguments.callee); }); }); $("#playControls").mouseout(function () { alert('here'); $("div").hide(2000); }); }); </script> </body> </html>

    Read the article

  • Tracking download of non-html (like pdf) downloads with jQuery and Google Analytics

    - by developerit
    Hi folks, it’s been quite calm at Developer IT’s this summer since we were all involved in other projects, but we are slowly comming back. In this post, we will present a simple way of tracking files download with Google Analytics with the help of jQuery. We work for a client that offers a lot of pdf files to download on their web site and wanted to know which one are the most popular. They use Google Analytics for a long time now and we did not want to have a second interface in order to present those stats to our client. So usign IIS logs was not a idea to consider. Since Google already offers us a splendid web interface and a powerful API, we deceided to hook up simple javascript code into the jQuery click event to notify Analytics that a pdf has been requested. (function ($) { function trackLink(e) { var url = $(this).attr('href'); //alert(url); // for debug purpose // old page tracker code pageTracker._trackPageview(url); // you can use the new one too _gaq.push(["_trackPageview",url]); //always return true, in order for the browser to continue its job return true; } // When DOM ready $(function () { // hook up the click event $('.pdf-links a').click(trackLink); }); })(jQuery); You can be more presice or even be sure not to miss one click by changing the selector which hooks up the click event. I have been usign this code to track AJAX requests and it works flawlessly.

    Read the article

  • jquery.ui.draggable.js and jquery.ui.widget.js conflict

    - by Daniel S
    hello I had a working application, which uses a jquery ui dialog. I wanted to make the dialog draggable. As far as I know the only thing needed is the jquery.ui.draggable.js script. So I added it to the scripts I am using, but know I get the following error (as shown in the firebug console): base is not a constructor The relevante line in jquery.ui.widget.js is: var basePrototype = new base(); This is how I am adding all the scripts: <script type="text/javascript" src="/media/development-bundle/jquery-1.4.2.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.core.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.draggable.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.position.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.autocomplete.js"></script> <script type="text/javascript" src="/media/development-bundle/ui/jquery.ui.dialog.js"></script> Am I doing something wrong? or is this a problem with jquery? Thanks in advance for any help

    Read the article

  • Clear form field after select for jQuery UI Autocomplete

    - by jonfhancock
    I'm developing a form, and using jQuery UI Autocomplete. When the user selects an option, I want the selection to pop into a span appended to the parent <p> tag. Then I want the field to clear rather than be populated with the selection. I have the span appearing just fine, but I can't get the field to clear. How do you cancel jQuery UI Autocomplete's default select action? Here is my code: var availableTags = ["cheese", "milk", "dairy", "meat", "vegetables", "fruit", "grains"]; $("[id^=item-tag-]").autocomplete({ source: availableTags, select: function(){ var newTag = $(this).val(); $(this).val(""); $(this).parent().append("<span>" + newTag + "<a href=\"#\">[x]</a> </span>"); } }); Simply doing $(this).val(""); doesn't work. What is maddening is that almost the exact function works fine if I ignore autocomplete, and just take action when the user types a comma as such: $('[id^=item-tag-]').keyup(function(e) { if(e.keyCode == 188) { var newTag = $(this).val().slice(0,-1); $(this).val(''); $(this).parent().append("<span>" + newTag + "<a href=\"#\">[x]</a> </span>"); } }); The real end result is to get autocomplete to work with multiple selections. If anybody has any suggestions for that, they would be welcome.

    Read the article

  • problem jquery.ui.autocomplete 1.8 with height and overflow with IE

    - by fabrice
    Hello, I have a probleme with jquery.ui.autocomplete 1.8 rc2 in IE7 or IE8 with the following CSS (inside jquery.ui.autocomplete.css) : .ui-menu { list-style:none; padding: 2px; margin: 0;display:block; height:200px; overflow:scroll; } I'm using the demo from the project called : demos\autocomplete\remote-jsonp.html It's working perfect with firefox but with IE7 or 8, each time I click on the scroll bar to see the end of the list, it selects an element instead of scrolling down. Do you please have a solution to have a fixed height with jquery.ui.autocomplete and a scroll bar working with IE ? Thank you very much

    Read the article

  • Cant get Jquery ui autocomplete widget to work

    - by Boob
    Im trying to develop my first ASP.NET MVC web app and have run into a problem with the jquery ui autocomplete widget. At the moment I have a form with a number of text boxs which would lend themselves well to an autocomplete ability. The code for my "Make"(Car make) text box is show below: jquery: $(function() { $("#Make").autocomplete({ source: '<%=Url.Action("Make","AutoComplete") %>' }); }); ASP.NET MVC controller: public ActionResult Make(string term) { return Json(Service.GetHints(HintType.Make, term, 20)); } GetHints() returns an IList of Hints, an object with just label and value string properties. The documentation implies that this is what I should be returning to the jquery but it doesnt want to work? Can anyone give me any advice/help?

    Read the article

  • jQuery opacity not working

    - by user1828505
    I am trying to change the opacity of the image after I click the red button instead of adding the different image, and I should not see the red button on the new image My JS code is below. http://jsfiddle.net/mwPeb/7/ <script> $(document).ready(function () { $(".specialHoverOne").hover(function () { // alert("i am here"); $(".ctaSpecialOne").css("visibility", "visible"); }, function () { $(".ctaSpecialOne").css("visibility", "hidden"); }); $(".ctaSpecialOne").click(function (e) { alert("clicked"); e.preventDefault(); //$(this).closest('.specialHoverOne').unbind("mouseenter").end().parent().siblings('a').children("img").attr("src", //"http://imgs.zinio.com/magimages/62898189/2012/416242497_200.jpg"); $(this).css({ 'opacity': 50 }); }); }); </script>

    Read the article

  • jquery Autocomplete : autocomplete does not stop if string does not match

    - by Daniyal
    I used the auto-complete function in jquery. It's data source are the results from a php-back-end. $("#ice_id").autocomplete("ice-ver.php", { extraParams : { flavour_id: $("#flavour_id").val() } }); Let us take following example: We type in the flavour ID 3992 ...(and 3992 exists in the database and is properly returned by the php backend). If we type in now 3992999 the auto-complete function should top showing anything up ...but unfortunately it still does, (could the problem lie within the fact that I am using integers instead of strings or chars?) Thanks in advance for any hints and best regards Daniyal

    Read the article

  • jquery opacity with another image

    - by user1828505
    i am trying to attatin the opacity of my image with book mark and cross image on it how to attain it i am providing my screenshot below docs.google.com/file/d/0B3IBJKENGE7RS1lwZzhYbTNRbkk/edit?pli=1 here is my js code jsfiddle.net/mwPeb/18 $(document).ready(function(){ $(".specialHoverOne").hover(function(){ // alert("i am here"); $(".ctaSpecialOne").css("visibility","visible"); }, function(){ $(".ctaSpecialOne").css("visibility","hidden"); } ); $(".ctaSpecialOne").click(function(e){ e.preventDefault(); $(this).parent().prev().prev().css({'opacity':.5}); $(this).remove(); }); });

    Read the article

  • Removing border from tab ui control

    - by oshirowanen
    I have the following script: http://jsfiddle.net/2HNvL/ but I can't seem to remove the light gray border around the tab control. Anyone here know how to do that? I have tried the following: #tabs .ui-widget { border:none; padding:0px; margin:0px; } #tabs .ui-widget-header { border:none; display:none; padding:0px; margin:0px; } #tabs .ui-widget-content { border:none; padding:0px; margin:0px; } But that does not work.

    Read the article

  • jQuery UI combobox Ajax options

    - by Mithun
    Hi, I need to customize the combobox widget build from the jQuery UI Autocomplete http://jqueryui.com/demos/autocomplete/#combobox Currently drop down options are predefined from the SELECT tag OPTIONS or from a JSON array. //getter var source = $( ".selector" ).autocomplete( "option", "source" ); //setter $( ".selector" ).autocomplete( "option", "source", ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] ); I want to populate the combobox options from a Ajax URL, how can i customize the widget?

    Read the article

  • JavaScript autocomplete upon typing

    - by James
    Right guys, all autocomplete plugins and functions that I've found, they only update upon keyup/down, etc. This is fine but the search only begins occurring once the user has stopped typing and if they are typing a phrase or word, the script is unable to instantly start suggesting, etc. I know this'll be a very simple fix or suggestion for some of you guys, so any help would be greatly appreciated as to how I can convert it to be instantly as a key is pressed. Thanks!

    Read the article

  • jQuery TypeError: example("input#autocomplete").autocomplete is not a function

    - by Ankush Kalia
    I have tried alot to remove this error but could not get success.When i am running this script on localhost its working fine but not working on Joomla frame work. The code is below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <?php $viewFields=array('c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby'); ?> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> var example=jQuery.noConflict(); var arrayFromPHP = <?php echo json_encode($viewFields) ?>; example(document).ready(function() { example("input#autocomplete").autocomplete({ source: arrayFromPHP }); }); </script> </head> <body> <center> <p><img src="<?php echo JURI::base(); ?>images/search_1.png" border="0" alt="" /> <img src="<?php echo JURI::base(); ?>images/business_2.png" border="0" alt="" /> <img src="<?php echo JURI::base(); ?>images/review_3.png" border="0" alt="" /> </p> </center> <input id="autocomplete" /> </body> </html> Its giving me this error:- -- [08:30:24.870] Use of getAttributeNode() is deprecated. Use getAttribute() instead. @ http://50.116.97.120/~amarhost/storage/media/system/js/mootools-core.js:343 [08:30:27.853] TypeError: example("input#autocomplete").autocomplete is not a function @ http://50.116.97.120/~amarhost/storage/index.php/component/storage/?action=war&Itemid=105:210

    Read the article

  • Change the default Icon on your jQuery UI Accordion

    - by hajan
    I've got this question in one of my previous blogs posted here (the same blog is posted on codeasp.net too), dealing with jQuery UI Accordion and I thought it's nice to recap this in a blog post so that I will have it documented for further reference. In the previous blog, I'm creating tabs content navigation using jQuery UI Accordion. So, it's quite simple code and all I do there is calling accordion() function. <script language="javascript" type="text/javascript">     $(function() {         $("#products").accordion();     }); </script> The default image icons for each item is the arrow. The accordion uses the right arrow and down arrow images. So, what we should do in order to change them? JQuery UI Accordion contains option with name icons that has header and headerSelected properties. We can override them with either the existing classes from jQuery UI themes or with our own. 1. Using existing jQuery UI Theme classes - Open the follownig link: http://jqueryui.com/themeroller/#icons You will see the icons available in the jQuery UI theme. Mouse over on each icon and you will see the class name for each icon. As you can see, each icon has class name constructed in the following way: ui-icon-<name> All icons in one image - In our example, I will use ui-icon-circle-plus  and ui-icon-circle-minus (plus and minus icons). - Lets set the icons <script language="javascript" type="text/javascript">     $(function() {         //initialize accordion                 $("#products").accordion();         //set accordion header options         $("#products").accordion("option", "icons",         { 'header': 'ui-icon-circle-plus', 'headerSelected': 'ui-icon-circle-minus' });     }); </script> From the code above, you can see that I first intialize the accordion plugin, and after I override the default icons with the ui-icon-circle-plyus for header and ui-icon-circle-minus for headerSelected. Here is the end result: So, now you see we have the plus/minus circle icons for the default header state and the selected header state.   2. Add my own icons - If you want to add your own icons, you can do that by creating your own custom css classes. - Lets create classes for both, the header default state and header selected state <style type="text/css">     .defaultIcon     {         background-image: url(images/icons/defaultIcon.png) !important;         width: 25px;         height: 25px;     }     .selectedIcon     {         background-image: url(images/icons/selectedIcon.png) !important;         width: 25px;         height: 25px;     } </style> As you can see, I use my own images placed in images/icons/ folder - default icon - selected icon One very important thing to note here is the !important key added on each background-image property. It's like that in order to give highest importancy to our image so that the default jQuery UI theme icon images will have less importancy and won't be used. And the jQuery code is: <script language="javascript" type="text/javascript">     $(function() {         //initialize accordion                 $("#products").accordion();         //set accordion header options         $("#products").accordion("option", "icons",         { 'header': 'defaultIcon', 'headerSelected': 'selectedIcon' });     }); </script> Note: For both #1 and #2 cases, we use the class names without adding . (dot) at the beginning of the name (as we do with selectors). That's because the the header and headerSelected properties accept classes only as a value, so the rest is done by the plugin itself. The complete code with my own custom images is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>jQuery Accordion</title>     <link type="text/css" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.5/themes/blitzer/jquery-ui.css"         rel="Stylesheet" />     <style type="text/css">         .defaultIcon         {             background-image: url(images/icons/defaultIcon.png) !important;             width: 25px;             height: 25px;         }         .selectedIcon         {             background-image: url(images/icons/selectedIcon.png) !important;             width: 25px;             height: 25px;         }     </style>     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.js"></script>     <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.js"></script>     <script language="javascript" type="text/javascript">         $(function() {             //initialize accordion                         $("#products").accordion();             //set accordion header options             $("#products").accordion("option", "icons",             { 'header': 'defaultIcon', 'headerSelected': 'selectedIcon' });         });             </script> </head> <body>     <form id="form1" runat="server">     <div id="products" style="width: 500px;">         <h3>             <a href="#">                 Product 1</a></h3>         <div>             <p>                 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus in tortor metus,                 a aliquam dui. Mauris euismod lorem eget nulla semper semper. Vestibulum pretium                 rhoncus cursus. Vestibulum rhoncus, magna sit amet fermentum fringilla, nunc nisl                 pellentesque libero, nec commodo libero ipsum a tellus. Maecenas sed varius est.                 Sed vel risus at nisi imperdiet sollicitudin eget ac orci. Duis ac tristique sem.             </p>         </div>         <h3>             <a href="#">                 Product 2</a></h3>         <div>             <p>                 Aliquam pretium scelerisque nisl in malesuada. Proin dictum elementum rutrum. Etiam                 eleifend massa id dui porta tincidunt. Integer sodales nisi nec ligula lacinia tincidunt                 vel in purus. Mauris ultrices velit quis massa dignissim rhoncus. Proin posuere                 convallis euismod. Vestibulum convallis sagittis arcu id faucibus.             </p>         </div>         <h3>             <a href="#">                 Product 3</a></h3>         <div>             <p>                 Quisque quis magna id nibh laoreet condimentum a sed nisl. In hac habitasse platea                 dictumst. Proin sem eros, dignissim sed consequat sit amet, interdum id ante. Ut                 id nisi in ante fermentum accumsan vitae ut est. Morbi tellus enim, convallis ac                 rutrum a, condimentum ut turpis. Proin sit amet pretium felis.             </p>             <ul>                 <li>List item one</li>                 <li>List item two</li>                 <li>List item three</li>             </ul>         </div>     </div>     </form> </body> </html> The end result is: Hope this was helpful. Regards,Hajan

    Read the article

  • Loading jQuery Consistently in a .NET Web App

    - by Rick Strahl
    One thing that frequently comes up in discussions when using jQuery is how to best load the jQuery library (as well as other commonly used and updated libraries) in a Web application. Specifically the issue is the one of versioning and making sure that you can easily update and switch versions of script files with application wide settings in one place and having your script usage reflect those settings in the entire application on all pages that use the script. Although I use jQuery as an example here, the same concepts can be applied to any script library - for example in my Web libraries I use the same approach for jQuery.ui and my own internal jQuery support library. The concepts used here can be applied both in WebForms and MVC. Loading jQuery Properly From CDN Before we look at a generic way to load jQuery via some server logic, let me first point out my preferred way to embed jQuery into the page. I use the Google CDN to load jQuery and then use a fallback URL to handle the offline or no Internet connection scenario. Why use a CDN? CDN links tend to be loaded more quickly since they are very likely to be cached in user's browsers already as jQuery CDN is used by many, many sites on the Web. Using a CDN also removes load from your Web server and puts the load bearing on the CDN provider - in this case Google - rather than on your Web site. On the downside, CDN links gives the provider (Google, Microsoft) yet another way to track users through their Web usage. Here's how I use jQuery CDN plus a fallback link on my WebLog for example: <!DOCTYPE HTML> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script> if (typeof (jQuery) == 'undefined') document.write(unescape("%3Cscript " + "src='/Weblog/wwSC.axd?r=Westwind.Web.Controls.Resources.jquery.js' %3E%3C/script%3E")); </script> <title>Rick Strahl's Web Log</title> ... </head>   You can see that the CDN is referenced first, followed by a small script block that checks to see whether jQuery was loaded (jQuery object exists). If it didn't load another script reference is added to the document dynamically pointing to a backup URL. In this case my backup URL points at a WebResource in my Westwind.Web  assembly, but the URL can also be local script like src="/scripts/jquery.min.js". Important: Use the proper Protocol/Scheme for  for CDN Urls [updated based on comments] If you're using a CDN to load an external script resource you should always make sure that the script is loaded with the same protocol as the parent page to avoid mixed content warnings by the browser. You don't want to load a script link to an http:// resource when you're on an https:// page. The easiest way to use this is by using a protocol relative URL: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> which is an easy way to load resources from other domains. This URL syntax will automatically use the parent page's protocol (or more correctly scheme). As long as the remote domains support both http:// and https:// access this should work. BTW this also works in CSS (with some limitations) and links. BTW, I didn't know about this until it was pointed out in the comments. This is a very useful feature for many things - ah the benefits of my blog to myself :-) Version Numbers When you use a CDN you notice that you have to reference a specific version of jQuery. When using local files you may not have to do this as you can rename your private copy of jQuery.js, but for CDN the references are always versioned. The version number is of course very important to ensure you getting the version you have tested with, but it's also important to the provider because it ensures that cached content is always correct. If an existing file was updated the updates might take a very long time to get past the locally cached content and won't refresh properly. The version number ensures you get the right version and not some cached content that has been changed but not updated in your cache. On the other hand version numbers also mean that once you decide to use a new version of the script you now have to change all your script references in your pages. Depending on whether you use some sort of master/layout page or not this may or may not be easy in your application. Even if you do use master/layout pages, chances are that you probably have a few of them and at the very least all of those have to be updated for the scripts. If you use individual pages for all content this issue then spreads to all of your pages. Search and Replace in Files will do the trick, but it's still something that's easy to forget and worry about. Personaly I think it makes sense to have a single place where you can specify common script libraries that you want to load and more importantly which versions thereof and where they are loaded from. Loading Scripts via Server Code Script loading has always been important to me and as long as I can remember I've always built some custom script loading routines into my Web frameworks. WebForms makes this fairly easy because it has a reasonably useful script manager (ClientScriptManager and the ScriptManager) which allow injecting script into the page easily from anywhere in the Page cycle. What's nice about these components is that they allow scripts to be injected by controls so components can wrap up complex script/resource dependencies more easily without having to require long lists of CSS/Scripts/Image includes. In MVC or pure script driven applications like Razor WebPages  the process is more raw, requiring you to embed script references in the right place. But its also more immediate - it lets you know exactly which versions of scripts to use because you have to manually embed them. In WebForms with different controls loading resources this often can get confusing because it's quite possible to load multiple versions of the same script library into a page, the results of which are less than optimal… In this post I look a simple routine that embeds jQuery into the page based on a few application wide configuration settings. It returns only a string of the script tags that can be manually embedded into a Page template. It's a small function that merely a string of the script tags shown at the begging of this post along with some options on how that string is comprised. You'll be able to specify in one place which version loads and then all places where the help function is used will automatically reflect this selection. Options allow specification of the jQuery CDN Url, the fallback Url and where jQuery should be loaded from (script folder, Resource or CDN in my case). While this is specific to jQuery you can apply this to other resources as well. For example I use a similar approach with jQuery.ui as well using practically the same semantics. Providing Resources in ControlResources In my Westwind.Web Web utility library I have a class called ControlResources which is responsible for holding resource Urls, resource IDs and string contants that reference those resource IDs. The library also provides a few helper methods for loading common scriptscripts into a Web page. There are specific versions for WebForms which use the ClientScriptManager/ScriptManager and script link methods that can be used in any .NET technology that can embed an expression into the output template (or code for that matter). The ControlResources class contains mostly static content - references to resources mostly. But it also contains a few static properties that configure script loading: A Script LoadMode (CDN, Resource, or script url) A default CDN Url A fallback url They are  static properties in the ControlResources class: public class ControlResources { /// <summary> /// Determines what location jQuery is loaded from /// </summary> public static JQueryLoadModes jQueryLoadMode = JQueryLoadModes.ContentDeliveryNetwork; /// <summary> /// jQuery CDN Url on Google /// </summary> public static string jQueryCdnUrl = "//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"; /// <summary> /// jQuery CDN Url on Google /// </summary> public static string jQueryUiCdnUrl = "//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"; /// <summary> /// jQuery UI fallback Url if CDN is unavailable or WebResource is used /// Note: The file needs to exist and hold the minimized version of jQuery ui /// </summary> public static string jQueryUiLocalFallbackUrl = "~/scripts/jquery-ui.min.js"; } These static properties are fixed values that can be changed at application startup to reflect your preferences. Since they're static they are application wide settings and respected across the entire Web application running. It's best to set these default in Application_Init or similar startup code if you need to change them for your application: protected void Application_Start(object sender, EventArgs e) { // Force jQuery to be loaded off Google Content Network ControlResources.jQueryLoadMode = JQueryLoadModes.ContentDeliveryNetwork; // Allow overriding of the Cdn url ControlResources.jQueryCdnUrl = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"; // Route to our own internal handler App.OnApplicationStart(); } With these basic settings in place you can then embed expressions into a page easily. In WebForms use: <!DOCTYPE html> <html> <head runat="server"> <%= ControlResources.jQueryLink() %> <script src="scripts/ww.jquery.min.js"></script> </head> In Razor use: <!DOCTYPE html> <html> <head> @Html.Raw(ControlResources.jQueryLink()) <script src="scripts/ww.jquery.min.js"></script> </head> Note that in Razor you need to use @Html.Raw() to force the string NOT to escape. Razor by default escapes string results and this ensures that the HTML content is properly expanded as raw HTML text. Both the WebForms and Razor output produce: <!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> if (typeof (jQuery) == 'undefined') document.write(unescape("%3Cscript src='/WestWindWebToolkitWeb/WebResource.axd?d=-b6oWzgbpGb8uTaHDrCMv59VSmGhilZP5_T_B8anpGx7X-PmW_1eu1KoHDvox-XHqA1EEb-Tl2YAP3bBeebGN65tv-7-yAimtG4ZnoWH633pExpJor8Qp1aKbk-KQWSoNfRC7rQJHXVP4tC0reYzVw2&t=634535391996872492' type='text/javascript'%3E%3C/script%3E"));</script> <script src="scripts/ww.jquery.min.js"></script> </head> which produces the desired effect for both CDN load and fallback URL. The implementation of jQueryLink is pretty basic of course: /// <summary> /// Inserts a script link to load jQuery into the page based on the jQueryLoadModes settings /// of this class. Default load is by CDN plus WebResource fallback /// </summary> /// <param name="url"> /// An optional explicit URL to load jQuery from. Url is resolved. /// When specified no fallback is applied /// </param> /// <returns>full script tag and fallback script for jQuery to load</returns> public static string jQueryLink(JQueryLoadModes jQueryLoadMode = JQueryLoadModes.Default, string url = null) { string jQueryUrl = string.Empty; string fallbackScript = string.Empty; if (jQueryLoadMode == JQueryLoadModes.Default) jQueryLoadMode = ControlResources.jQueryLoadMode; if (!string.IsNullOrEmpty(url)) jQueryUrl = WebUtils.ResolveUrl(url); else if (jQueryLoadMode == JQueryLoadModes.WebResource) { Page page = new Page(); jQueryUrl = page.ClientScript.GetWebResourceUrl(typeof(ControlResources), ControlResources.JQUERY_SCRIPT_RESOURCE); } else if (jQueryLoadMode == JQueryLoadModes.ContentDeliveryNetwork) { jQueryUrl = ControlResources.jQueryCdnUrl; if (!string.IsNullOrEmpty(jQueryCdnUrl)) { // check if jquery loaded - if it didn't we're not online and use WebResource fallbackScript = @"<script type=""text/javascript"">if (typeof(jQuery) == 'undefined') document.write(unescape(""%3Cscript src='{0}' type='text/javascript'%3E%3C/script%3E""));</script>"; fallbackScript = string.Format(fallbackScript, WebUtils.ResolveUrl(ControlResources.jQueryCdnFallbackUrl)); } } string output = "<script src=\"" + jQueryUrl + "\" type=\"text/javascript\"></script>"; // add in the CDN fallback script code if (!string.IsNullOrEmpty(fallbackScript)) output += "\r\n" + fallbackScript + "\r\n"; return output; } There's one dependency here on WebUtils.ResolveUrl() which resolves Urls without access to a Page/Control (another one of those features that should be in the runtime, not in the WebForms or MVC engine). You can see there's only a little bit of logic in this code that deals with potentially different load modes. I can load scripts from a Url, WebResources or - my preferred way - from CDN. Based on the static settings the scripts to embed are composed to be returned as simple string <script> tag(s). I find this extremely useful especially when I'm not connected to the internet so that I can quickly swap in a local jQuery resource instead of loading from CDN. While CDN loading with the fallback works it can be a bit slow as the CDN is probed first before the fallback kicks in. Switching quickly in one place makes this trivial. It also makes it very easy once a new version of jQuery rolls around to move up to the new version and ensure that all pages are using the new version immediately. I'm not trying to make this out as 'the' definite way to load your resources, but rather provide it here as a pointer so you can maybe apply your own logic to determine where scripts come from and how they load. You could even automate this some more by using configuration settings or reading the locations/preferences out of some sort of data/metadata store that can be dynamically updated instead via recompilation. FWIW, I use a very similar approach for loading jQuery UI and my own ww.jquery library - the same concept can be applied to any kind of script you might be loading from different locations. Hopefully some of you find this a useful addition to your toolset. Resources Google CDN for jQuery Full ControlResources Source Code ControlResource Documentation Westwind.Web NuGet This method is part of the Westwind.Web library of the West Wind Web Toolkit or you can grab the Web library from NuGet and add to your Visual Studio project. This package includes a host of Web related utilities and script support features. © Rick Strahl, West Wind Technologies, 2005-2011Posted in ASP.NET  jQuery   Tweet (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • jQuery Autocomplete using extraParams to pass additional GET variables

    - by paperclip
    I am referring specifically to the jQuery Autocomplete v1.1 plugin by Jörn Zaefferer [source: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/] as there seems to be quite a few variations of this plugin. I'm trying to pass additional parameters to the server when the user starts typing because I have multiple fields that I want autocomplete to provide suggestions for. In addition to the query, I want to send the input name attribute to the server but I can't seem to use $(this).attr('name') within the extraParams. My jQuery: $('.ajax-auto input').autocomplete('search.php', { extraParams: { search_type: function(){ return $(this).attr('name'); } } }) This is my HTML. <form method="post" action="#" id="update-form" autocomplete="off"> <ol> <li class="ajax-auto"> <label for="form-initials">Initials</label> <input type="text" id="form-initials" name="initials" /> </li> <li class="ajax-auto"> <label for="form-company">Company</label> <input type="text" id="form-company" name="company" /> </li> </ol> </form> Any suggestions?

    Read the article

  • Facebook style JQuery autocomplete plugin

    - by Luke Lowrey
    Im after a plugin to do autocomplete like facebook does in that you can select multiple items - similar to how tagging a stackoverflow question works. Here are a couple I ran into: http://wharsojo.wordpress.com/2008/02/18/jquery-facebook-autocomplete http://www.emposha.com/javascript/fcbkcomplete.html http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/ Have you tried any of these? Were they easy to implement and customize?

    Read the article

  • jQuery Autocomplete problem - Shift Key behaves same as Return Key

    - by user237005
    See: http://www.airbnb.com/ In the search bar, start typing "san f" (no quotes, all lowercase), then hit Return (or Enter). "San Francisco" is autocompleted. This is good! Now clear the search field and start over. type "San F" and boom - "San Francisco" is autocompleted as soon as you hit Shift. This is not expected. This happens in FF & Safari, but is untested elsewhere. I've looked through the jQuery Autocomplete Source Code and everything looks normal. Has anyone experienced this before?

    Read the article

  • Using 2 JQuery Autocomplete

    - by Trike
    Hi All! I am using the JQuery Autocomplete Plugin 1.1. When I try to add autocomplete to 2 inputs in this way: $("#object_ac").autocomplete("autocomplete_search.php", { extraParams: {object:1}, width: 160, selectFirst: false, minChars: 2 }); $("#id_norm_doc_ac").autocomplete("autocomplete_search.php", { width: 460, selectFirst: false, mustMatch: true }); $("#id_norm_doc_ac").result(function(event, data, formatted) { $("#id_norm_doc_add").val(data[1]); }); When #object_ac selected before #id_norm_doc_ac I get error after selecting one of suggestions in #id_norm_doc_ac: data is undefined [Break on this error] data = elementToString(data.documentElement, true); If I select #id_norm_doc_ac before other inputs, everything goes normal. Thanks in advance for any assistance!

    Read the article

  • JQuery Autocomplete Where the Results are Links

    - by Spencer
    I am trying to create a JQuery Autocomplete box where the words being suggested for autcomplete are links (similar to what happens on Facebook or Quora). Basically, I want the autocomplete results to drop down and I want people to be able to click on them and be navigated to a different page. Here is the code I am currently using <!DOCTYPE html> <html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { $("input#autocomplete").autocomplete({ source: ["Spencer Kline", "Test Test Test Test Test Test Test Test Test", "php", "coldfusion", "javascript", "asp", "ruby"] }); }); </script> </head> <body style="font-size:62.5%;"> <input id="autocomplete" /> </body> </html>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >