Search Results

Search found 22025 results on 881 pages for 'jquery filter'.

Page 7/881 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Having Many Problems with Jquery UI 1.8.1 Dialog.js

    - by chobo2
    Hi I been using the jquery ui for quite a while now. This is the first time using 1.8 though and I am not sure why but it seems to me this plugin has taken steps backwards. I never had so much difficulty to use the Jquery UI as I am having now. First the documentation is out of date. Dependencies * UI Core * UI Draggable (Optional) * UI Resizable (Optional) After line 20mins of trying and getting error after error (like dialog is not a function) I realized that you need some other javascript file called "widget.js" So now I have Jquery 1.4.2.js UI Core.js UI Widget.js UI Dialog.js all on my page. I then did something like this $('#Delete').click(function () { var dialogId = "DeleteDialogBox"; var createdDialog = MakeDialogBox(dialogId, "Delete Conformation"); $('#tabConent').after(createdDialog); dialogId = String.format('#{0}', dialogId); $(dialogId).dialog({ resizable: true, height: 500, width: 500, modal: true, buttons: { 'Delete all items': function() { $(this).dialog('close'); }, Cancel: function() { $(this).dialog('close'); } } }); }); function MakeDialogBox(id, title) { var dialog = String.format('<div id="{0}" title="{1}"></div>', id, title); return dialog; } Now what this should be doing is it makes a where the dialog box should go. After that it should put it right after my tabs. So when watching it with firebug it does this. However once does the .dialog() method it moves the + all the stuff it generates and puts it after my footer. So now I have my dialog box under my footer tucked away in the bottom right hand corner. I want it dead in the center. In previous versions I don't think it mattered where the dialog code was on your page it would always be dead center. So what am I missing? The center.js(I don't know if this exists but seems like you need 100 javascript files now to get this to work proper).

    Read the article

  • JQuery - Ajax saving sortables in connected lists when sortable item is moved

    - by Ben Sinclair
    I have multiple JQuery sortable lists that connect with each other... They allow you to assign users to certain roles. Basically what I want to do is when a user is dragged from one list to another, I want JQuery to pick up the first list that the user was moved from so that I can send an AJAX request to delete it from that list in my database. I tried the following but every time you move the user over a list and haven't even dropped it within a list, it sends this request which means I'll be sending multiple AJAX requests... Does that make sense? $( ".selector" ).sortable({ out: function(event, ui) { ... } }); From my testing, I can use the following code to just update the list that user has been moved to so I've got the second half covered: $( ".selector" ).sortable({ receive: function(event, ui) { ... } }); Hopefully I am making sense :)

    Read the article

  • can you explain this jquery method from jquery.js

    - by mrblah
    Trying to understand how jquery works under the covers, what's the difference between: jQuery.fn and jQuery.prototype jQuery = window.jQuery = window.$ = function( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init( selector, context ); }, and then: jQuery.fn = jQuery.prototype = { init: function( selector, context ) {

    Read the article

  • JQuery UI Dialog query dialog DOM

    - by Travis
    The following simply loads a jquery-ui dialog from an external html file. $('#showdialog').click(function(e) { var div = $('<div>loading...</div>'); div.dialog({ modal: true, open: function() { div.load('anotherpage.html'); } }); e.preventDefault(); }); After the DOM loads from the external html file, I'd like to interrogate it with JQuery. For example, supposing anothorpage.html had a bunch of anchors on it, I'd like to wire up click handlers for them when it loads into the dialog. Any ideas?

    Read the article

  • Jquery mouseover event issues

    - by Shaun
    Hi I am currently working on a project where I am using jQuery to animate a block of text on mouse over. The event listener is on the containing div (as shown by the code below) and works really well until the mouse is over the title (.views-field-title) which is absolutely above the containing div. The animation begins to jump almost as though it is starting over? What am I doing wrong? $('#interior_design .views-row').mouseover(function(){ $('.views-field-title', this).stop(true, true).animate( { height: '+=10px' }, { duration: 'fast'}); }); $('#interior_design .views-row').mouseout(function(){ $('.views-field-title', this).stop(true, true).animate( { height: '-=10px' }, { duration: 'fast'}); }); Link to dev server: http://viva.bangtest.co.uk/interior-design Note: this site is still in development as such the jQuery is only on the above linked page currently. I'm open to all suggestions.

    Read the article

  • jQuery droppable accordion

    - by awshepard
    I've been playing around with trying to create a droppable accordion for a little while, and haven't gotten it to be very responsive. When I drag an item over the accordion, it takes 5+ seconds for the accordion element to open (if it does at all). Sometimes I have to "wave" the dragged element over the accordion element. I know I read something a while back about event processing in javascript - something along the lines of the browser not always passing control to the javascript engine when you think it does, or something like that, resulting in weird timing. Has anyone else seen tried to do this before? Have you found jquery/javascript to be this slow? Do you have any references for how to get a responsive droppable accordion (the jQuery UI site doesn't seem to, and I didn't find anything on SO or Google). Thanks!

    Read the article

  • jQuery: jquery form plugin syntax?

    - by k00k
    I'm using jquery with the jquery form plugin. I read through a bunch of posts, the docs, etc., and I'm still having trouble with what I believe to be simple. I have a form with some simple text inputs and a couple textareas, and I have this link that I want to trigger submission of that form to a specific method (/email): <a id="email-data">Send Email</a> and this jquery in doc ready: $('#email-data').click(function() { var options = { url: '/email/', success: alert('Email sent.') }; $('#report-giftcard-sales-form').ajaxSubmit(options); }); So I would expect it to submit to my /email method, but no such luck. Currently I just have the /email method logging a debug message, so it's as simple as can be. Any help is greatly appreciated.

    Read the article

  • How can I check if a particular jQuery UI function is available and use a different function if it i

    - by Mark B
    I'm writing a jQuery plugin and I would like my code to take advantage of the jQuery UI show(effect, [options], [speed], [callback]) and hide(effect, [options], [speed], [callback]) functions, which allow you to show and hide elements with a nice animation. However, I'd also like my plugin to degrade gracefully if jQuery UI isn't available, switching back to use the basic, non-animating show() and hide() functions present in the standard jQuery API. I'll need to test for the show and hide functions specifically, as even if jQuery UI is available it could potentially be a custom version, without the Effects components included. At first I thought that I might be able to do something like: if(typeof myelement.show('blind', 'slow') == 'undefined') { myelement.show('blind', 'slow'); } else { myelement.show(); } But of course this doesn't work, as even if UI isn't present, show() is still a function, it just has a different signature—so typeof returns object in either case. So, what's the best way for me to check if jQuery UI is available to my plugin? Any help is much appreciated!

    Read the article

  • clicking anchor element within jquery tab loads new page *outside* tab

    - by tabs_newbie
    Hello, I would like to be able to click on an achor element from a page inside a jQuery tab and have that new page load directly inside the original tab. I used sample code from the jQuery tutorial page but to no avail! When I click on the anchor tag, I get redirected to www.google.com but lose my tabs. Does anyone know what I'm doing wrong? would really appreciate it. Thanks! $(document).ready(function(){ $("#tabs").tabs(); }); $('#tabs').tabs({ load: function(e, ui) { $('a', ui.panel).click(function() { $(ui.panel).load(this.href); return false; }); } });

    Read the article

  • jQuery UI Element vs Dojo (Dijit) Form Element

    - by Muers
    Dojo seems to have a useful feature in that it can setup event handlers and default options, etc for Dijit.form elements as it is inserting it into the DOM. For example, Dojo: var slider = new dijit.form.HorizontalSlider({ name: sliderContainerId+'_slider', value: sliderValue, minimum: sliderMax, maximum: sliderMin, onChange: function(value){ // some event handling logic } }, sliderContainerId); However, the jQuery UI Slider traditionally is applied to DOM elements that already exist: $( sliderContainerId ).slider({ value:100, min: 0, max: 500, step: 50, slide: function( event, ui ) { $( "#amount" ).val( "$" + ui.value ); } }); I need to be able to 'programmatically' create new Sliders (and other form elements), but I'm not sure how that could be achieved with the way jQuery is structured? Maybe I'm missing something obvious here.... MTIA

    Read the article

  • Filtering List Data with a jQuery-searchFilter Plugin

    - by Rick Strahl
    When dealing with list based data on HTML forms, filtering that data down based on a search text expression is an extremely useful feature. We’re used to search boxes on just about anything these days and HTML forms should be no different. In this post I’ll describe how you can easily filter a list down to just the elements that match text typed into a search box. It’s a pretty simple task and it’s super easy to do, but I get a surprising number of comments from developers I work with who are surprised how easy it is to hook up this sort of behavior, that I thought it’s worth a blog post. But Angular does that out of the Box, right? These days it seems everybody is raving about Angular and the rich SPA features it provides. One of the cool features of Angular is the ability to do drop dead simple filters where you can specify a filter expression as part of a looping construct and automatically have that filter applied so that only items that match the filter show. I think Angular has single handedly elevated search filters to first rate, front-row status because it’s so easy. I love using Angular myself, but Angular is not a generic solution to problems like this. For one thing, using Angular requires you to render the list data with Angular – if you have data that is server rendered or static, then Angular doesn’t work. Not all applications are client side rendered SPAs – not by a long shot, and nor do all applications need to become SPAs. Long story short, it’s pretty easy to achieve text filtering effects using jQuery (or plain JavaScript for that matter) with just a little bit of work. Let’s take a look at an example. Why Filter? Client side filtering is a very useful tool that can make it drastically easier to sift through data displayed in client side lists. In my applications I like to display scrollable lists that contain a reasonably large amount of data, rather than the classic paging style displays which tend to be painful to use. So I often display 50 or so items per ‘page’ and it’s extremely useful to be able to filter this list down. Here’s an example in my Time Trakker application where I can quickly glance at various common views of my time entries. I can see Recent Entries, Unbilled Entries, Open Entries etc and filter those down by individual customers and so forth. Each of these lists results tends to be a few pages worth of scrollable content. The following screen shot shows a filtered view of Recent Entries that match the search keyword of CellPage: As you can see in this animated GIF, the filter is applied as you type, displaying only entries that match the text anywhere inside of the text of each of the list items. This is an immediately useful feature for just about any list display and adds significant value. A few lines of jQuery The good news is that this is trivially simple using jQuery. To get an idea what this looks like, here’s the relevant page layout showing only the search box and the list layout:<div id="divItemWrapper"> <div class="time-entry"> <div class="time-entry-right"> May 11, 2014 - 7:20pm<br /> <span style='color:steelblue'>0h:40min</span><br /> <a id="btnDeleteButton" href="#" class="hoverbutton" data-id="16825"> <img src="images/remove.gif" /> </a> </div> <div class="punchedoutimg"></div> <b><a href='/TimeTrakkerWeb/punchout/16825'>Project Housekeeping</a></b><br /> <small><i>Sawgrass</i></small> </div> ... more items here </div> So we have a searchbox txtSearchPage and a bunch of DIV elements with a .time-entry CSS class attached that makes up the list of items displayed. To hook up the search filter with jQuery is merely a matter of a few lines of jQuery code hooked to the .keyup() event handler: <script type="text/javascript"> $("#txtSearchPage").keyup(function() { var search = $(this).val(); $(".time-entry").show(); if (search) $(".time-entry").not(":contains(" + search + ")").hide(); }); </script> The idea here is pretty simple: You capture the keystroke in the search box and capture the search text. Using that search text you first make all items visible and then hide all the items that don’t match. Since DOM changes are applied after a method finishes execution in JavaScript, the show and hide operations are effectively batched up and so the view changes only to the final list rather than flashing the whole list and then removing items on a slow machine. You get the desired effect of the list showing the items in question. Case Insensitive Filtering But there is one problem with the solution above: The jQuery :contains filter is case sensitive, so your search text has to match expressions explicitly which is a bit cumbersome when typing. In the screen capture above I actually cheated – I used a custom filter that provides case insensitive contains behavior. jQuery makes it really easy to create custom query filters, and so I created one called containsNoCase. Here’s the implementation of this custom filter:$.expr[":"].containsNoCase = function(el, i, m) { var search = m[3]; if (!search) return false; return new RegExp(search, "i").test($(el).text()); }; This filter can be added anywhere where page level JavaScript runs – in page script or a seperately loaded .js file.  The filter basically extends jQuery with a : expression. Filters get passed a tokenized array that contains the expression. In this case the m[3] contains the search text from inside of the brackets. A filter basically looks at the active element that is passed in and then can return true or false to determine whether the item should be matched. Here I check a regular expression that looks for the search text in the element’s text. So the code for the filter now changes to:$(".time-entry").not(":containsNoCase(" + search + ")").hide(); And voila – you now have a case insensitive search.You can play around with another simpler example using this Plunkr:http://plnkr.co/edit/hDprZ3IlC6uzwFJtgHJh?p=preview Wrapping it up in a jQuery Plug-in To make this even easier to use and so that you can more easily remember how to use this search type filter, we can wrap this logic into a small jQuery plug-in:(function($, undefined) { $.expr[":"].containsNoCase = function(el, i, m) { var search = m[3]; if (!search) return false; return new RegExp(search, "i").test($(el).text()); }; $.fn.searchFilter = function(options) { var opt = $.extend({ // target selector targetSelector: "", // number of characters before search is applied charCount: 1 }, options); return this.each(function() { var $el = $(this); $el.keyup(function() { var search = $(this).val(); var $target = $(opt.targetSelector); $target.show(); if (search && search.length >= opt.charCount) $target.not(":containsNoCase(" + search + ")").hide(); }); }); }; })(jQuery); To use this plug-in now becomes a one liner:$("#txtSearchPagePlugin").searchFilter({ targetSelector: ".time-entry", charCount: 2}) You attach the .searchFilter() plug-in to the text box you are searching and specify a targetSelector that is to be filtered. Optionally you can specify a character count at which the filter kicks in since it’s kind of useless to filter at a single character typically. Summary This is s a very easy solution to a cool user interface feature your users will thank you for. Search filtering is a simple but highly effective user interface feature, and as you’ve seen in this post it’s very simple to create this behavior with just a few lines of jQuery code. While all the cool kids are doing Angular these days, jQuery is still useful in many applications that don’t embrace the ‘everything generated in JavaScript’ paradigm. I hope this jQuery plug-in or just the raw jQuery will be useful to some of you… Resources Example on Plunker© Rick Strahl, West Wind Technologies, 2005-2014Posted in jQuery  HTML5  JavaScript   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (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 Animate Inconsistencies between Browsers

    - by silent1mezzo
    I'm trying to figure out why this works in FireFox, Chrome but not in IE and not properly in Safari and Opera (you can view it working at http://41six.com/about/) HTML: <div id="menu"> <ul> <li> <a href="/" class="home" title="Home" alt="fortyonesix">&nbsp;</a> <div id='home-hover'>Home Page</div> </li> </ul> </div> CSS: #menu .home { display:block; height:24px; width:24px; background-image: url('../images/Home.png'); } #home-hover { position:fixed; padding: 3px 0 3px 10px; left:40px; top:125px; width: 100px; height: 20px; background-color:#000; color: #fff; z-index:9999; opacity: .9; filter: alpha(opacity=90); -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=90)"; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-top-bottom-radius: 5px; display:none; } JQuery: $('.home').hover(function() { $('#home-hover').animate({width:'toggle'},200); }, function() { $('#home-hover').animate({width:'toggle'},200); }); It's definitely not pretty but I'm not sure why its not working for Safari, Opera and IE

    Read the article

  • Jquery autocomplete UI - No results on multiple fields

    - by pjammer
    Andrew's answer to my comment has sparked this question. According to his awesome answer in the link above, the code at the bottom of the question will only work for ONE widget. But it's killer nice code and makes sense... I guess I want the best of both worlds. Nice JS, (if that is possible) and to have the zero results show() just the element that we're using at the time. This code snippet is the main crux of my problem, as I see it: source: function (request, response) { jQuery.ajax({ url: "/autocomplete.json", data: { term: request.term }, success: function (data) { if (data.length == 0) { jQuery('span.guest_investor_email').show(); jQuery('span.investor_field_delete_button').show(); } response(data); } }); Currently: I have a button on my page that says "Add more Information" and each time you click it, a new instance of the autocomplete text field appears, complete with some hidden fields and a display:none; on guest_investor_email. If I use the autocomplete text field, say 3 times, and i have 3 autocomplete instances on the page and the third one finds 0 results: The code will show() all 3 instances of the guest_investor_email text field, instead of just this one that is blank. QUESTION: How do i get something like jQuery(this).siblings(('span.guest_investor_email').show(); to work? this is an Object and not an array of elements to select. If it isn't with this I don't mind, as long as I know how to get at it. Thanks. Full Code: jQuery(".auto_search_complete").live("click", function() { jQuery(this).autocomplete({ minLength: 3, source: function (request, response) { jQuery.ajax({ url: "/autocomplete.json", data: { term: request.term }, success: function (data) { if (data.length == 0) { jQuery('span.guest_investor_email').show(); jQuery('span.investor_field_delete_button').show(); } response(data); } }); }, focus: function(event, ui) { jQuery(this).val(ui.item.user ? ui.item.user.name : ui.item.pitch.name); return false; }, select: function(event, ui) { jQuery(this).val(ui.item.user ? ui.item.user.name : ui.item.pitch.name); jQuery(this).siblings('div.hidden_fields').children('.poly_id').val(ui.item.user ? ui.item.user.id : ui.item.pitch.id); jQuery(this).siblings('div.hidden_fields').children('.poly_type').val(ui.item.user ? "User" : "Pitch"); jQuery(this).siblings('span.guest_investor_email').hide(); jQuery(this).siblings('span.investor_field_delete_button').show(); jQuery(this).attr('readonly','readonly'); jQuery(this).attr('id', "investor-selected"); return false; } }).each(function() { jQuery(this).data( "autocomplete" )._renderItem = function( ul, item ) { return jQuery( "" ) .data( "item.autocomplete", item ) .append("" + (item.user ? item.user.name : item.pitch.name) + "" + (item.user ? item.user.investor_type : item.pitch.investor_type) + " - " + (item.user ? item.user.city : item.pitch.city) + "" ) .appendTo( ul ); }; }); });

    Read the article

  • Best method to select an object from another unknown jQuery object

    - by Yosi
    Lets say I have a jQuery object/collection stored in a variable named obj, which should contain a DOM element with an id named target. I don't know in advance if target will be a child in obj, i.e.: obj = $('<div id="parent"><div id="target"></div></div>'); or if obj equals target, i.e.: obj = $('<div id="target"></div>'); or if target is a top-level element inside obj, i.e.: obj = $('<div id="target"/><span id="other"/>'); I need a way to select target from obj, but I don't know in advance when to use .find and when to use .filter. What would be the fastest and/or most concise method of extracting target from obj? What I've come up with is: var $target = obj.find("#target").add(obj.filter("#target")); UPDATE I'm adding solutions to a JSPERF test page to see which one is the best. Currently my solution is still the fastest. Here is the link, please run the tests so that we'll have more data: http://jsperf.com/jquery-selecting-objects

    Read the article

  • jQuery Validate - require at least one field in a group to be filled

    - by Nathan Long
    I'm using the excellent jQuery Validate Plugin to validate some forms. On one form, I need to ensure that the user fills in at least one of a group of fields. I think I've got a pretty good solution, and wanted to share it. Please suggest any improvements you can think of. Finding no built-in way to do this, I searched and found Rebecca Murphey's custom validation method, which was very helpful. I improved this in three ways: To let you pass in a selector for the group of fields To let you specify how many of that group must be filled for validation to pass To show all inputs in the group as passing validation as soon as one of them passes validation. So you can say "at least X inputs that match selector Y must be filled." The end result is a rule like this: partnumber: { require_from_group: [2,".productinfo"] } //The partnumber input will validate if //at least 2 `.productinfo` inputs are filled For best results, put this rule AFTER any formatting rules for that field (like "must contain only numbers", etc). This way, if the user gets an error from this rule and starts filling out one of the fields, they will get immediate feedback about the formatting required without having to fill another field first. Item #3 assumes that you're adding a class of .checked to your error messages upon successful validation. You can do this as follows, as demonstrated here. success: function(label) { label.html(" ").addClass("checked"); } As in the demo linked above, I use CSS to give each span.error an X image as its background, unless it has the class .checked, in which case it gets a check mark image. Here's my code so far: jQuery.validator.addMethod("require_from_group", function(value, element, options) { // From the options array, find out what selector matches // our group of inputs and how many of them should be filled. numberRequired = options[0]; selector = options[1]; var commonParent = $(element).parents('form'); var numberFilled = 0; commonParent.find(selector).each(function(){ // Look through fields matching our selector and total up // how many of them have been filled if ($(this).val()) { numberFilled++; } }); if (numberFilled >= numberRequired) { // This part is a bit of a hack - we make these // fields look like they've passed validation by // hiding their error messages, etc. Strictly speaking, // they haven't been re-validated, though, so it's possible // that we're hiding another validation problem. But there's // no way (that I know of) to trigger actual re-validation, // and in any case, any other errors will pop back up when // the user tries to submit the form. // If anyone knows a way to re-validate, please comment. // // For imputs matching our selector, remove error class // from their text. commonParent.find(selector).removeClass('error'); // Also look for inserted error messages and mark them // with class 'checked' var remainingErrors = commonParent.find(selector) .next('label.error').not('.checked'); remainingErrors.text("").addClass('checked'); // Tell the Validate plugin that this test passed return true; } // The {0} in the next line is the 0th item in the options array }, jQuery.format("Please fill out at least {0} of these fields.")); Questions? Comments?

    Read the article

  • jQuery sortable Div's

    - by kai lange
    is it possible to sort direct between two or more div's/boxe's and return the complete data (var order = ...) ? Online Demo: http://jsbin.com/alegu4 <!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=utf-8" /> <title>jQuery Dynamic Drag'n Drop</title> <script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"></script> <style> body { font-family: Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 10px; } ul { margin: 0; } #s1,#s2 { float: left; width: 400px; } #s1 li,#s2 li { list-style: none; margin: 0 0 4px 0; padding: 10px; background-color:#00CCCC; border: #CCCCCC solid 1px; color:#fff; } </style> <script type="text/javascript"> $(document).ready(function(){ $(function() { $("#s1 ul,#s2 ul").sortable({ opacity: 0.6, cursor: 'move', update: function() { var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; //$.post("updateDB.php", order); alert(order); } }); }); }); </script> </head> <body> <div id="box"> <div class="box" id="s1"> <ul> <li id="recordsArray_1">1. Lorem ipsum dolor sit amet, consetetur</li> <li id="recordsArray_2">2. Lorem ipsum dolor sit amet, consetetur</li> <li id="recordsArray_3">3. Lorem ipsum dolor sit amet, consetetur</li> <li id="recordsArray_4">4. Lorem ipsum dolor sit amet, consetetur</li> </ul> </div> <div class="box" id="s2"> <ul> <li id="recordsArray_5">5. Lorem ipsum dolor sit amet, consetetur</li> <li id="recordsArray_6">6. Lorem ipsum dolor sit amet, consetetur</li> <li id="recordsArray_7">7. Lorem ipsum dolor sit amet, consetetur</li> <li id="recordsArray_8">8. Lorem ipsum dolor sit amet, consetetur</li> </ul> </div> </div> </body> </html> Please note it's not the same like my other post - thanks!

    Read the article

  • I need help understanding how this jQuery filter function works, line-by-line, if possible

    - by user717236
    Here is the HTML: <div> <h3>text</h3> </div> <div> <h3>moretext</h3> </div> <div> <h3>123</h3> </div>?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Here is the JS: var rv1_wlength = $("div").filter(function() { return $(this).find("h3").filter(function () { return $(this).text() != "123"; }).length; }); var rv1_wolength = $("div").filter(function() { return $(this).find("h3").filter(function () { return $(this).text() != "123"; }); }); var rv2 = $("div").find("h3").filter(function() { return $(this).text() != "123"; }); alert(rv1_wlength.text()); // text // moretext alert(rv1_wolength.text()); // text // moretext // 123 alert(rv2.text());? // textmoretext I don't understand why the first two methods print the elements on each line, whereas the second method concatenates them. "rv2" is a jQuery object. Then, what are the first two (rv1_wlength and rv1_wolength)? Furthermore, I don't understand why the inclusion of the length property makes all the difference in filtering the elements. The second method does nothing, since it returns all the elements. The first method, with the only change being the addition of the length property, correctly filters the elements. I would very much like a line-by-line explanation. I would sincerely appreciate any feedback. Thank you.

    Read the article

  • jQuery datepicker validation message issue

    - by Abhishek
    Hi, I'm using the jquery datepicker plugin at http://plugins.jquery.com/project/datepick with the datepicker validation plugin. <script id="frmValidation" type="text/javascript"> $(document).ready(function(){ var validator = $("#frmTest").validate({ rules:{ fname: "required", dobPicker: "required" }, messages:{ fname: "Please enter a name", dobPicker: "Select a date" }, }); $('#dobPicker').datepick(); $.datepick.setDefaults({showOn: 'both', dateFormat: 'dd-mm-yy', yearRange:'1900:2010'}); }); </script> And the body of the document is as follows : <form id="frmTest" action="" method="post"> <div id="error-list"></div> <div class="form-row"> <span class="label"><label for="fname">Name</label></span> <input type="text" name="fname" /> </div> <div class="form-row"> <span class="label"><label for="dobPicker">DOB</label></span> <input type="text" id="dobPicker" name="dobPicker" style="margin-left: 4px;"/> </div> <div class="form-row"> <input type="submit" name="submit" value="submit"/> </div> </form> The form validates the first time but the error message for the datepicker does not disappear immediately a date is selected.. however it goes away if the date is selected the second time. Any help to make it go the first time a date is selected will be appreciated

    Read the article

  • jQuery AutoComplete Plugin not working for JSON Response (sValue.substring is not a function)

    - by Sunday Ironfoot
    I'm trying to use the autocomplete plugin for jQuery (this one http://docs.jquery.com/Plugins/Autocomplete). My server is returning JSON string, which I'm trying to process on the client via AutoComplete plugin's 'parse' and 'formatItem' parameters, like so: $(document).ready(function() { $('.searchBox input.textbox').autocomplete('/DoSearch.aspx', { mustMatch: false, autoFill: true, minChars: 1, dataType: 'json', parse: function(data) { var array = new Array(); for (var i = 0; i < data.length; i++) { array[array.length] = { data: data[i], value: data[i].ID, result: data[i].ID }; } return array; }, formatItem: function(row, i, n) { return row.ID + ': ' + row.Title; } }); }); When I run this I get a 'sValue.substring is not a function' error thrown in Firebug. However, if I stick breakpoints on formatItem and parse function, they are hit as expected and contain valid data it seems. Here is an exact copy 'n' paste of the JSON text that gets returned from the server: [{"ID":140177,"Title":"Food Handling","Code":"J01.576.423.200"},{"ID":140178,"Title":"Food Handling","Code":"J01.576.423.200"},{"ID":140179,"Title":"Brain Infarction","Code":"C10.228.140.300.301.200"},{"ID":140180,"Title":"Cerebral Hemorrhage","Code":"C10.228.140.300.535.200"},{"ID":140182,"Title":"Insulin","Code":"D06.472.610.575"},{"ID":140183,"Title":"Insulin","Code":"D06.472.610.575"},{"ID":140184,"Title":"Insulin","Code":"D06.472.610.575"},{"ID":140186,"Title":"Insulin","Code":"D06.472.610.575"},{"ID":140188,"Title":"Insulin","Code":"D06.472.610.575"},{"ID":140189,"Title":"Sulfonylurea Compounds","Code":"D02.886.590.795"}] Please help, I've already searched Google and StackOverflow for help, but can't find anyone having else this error, cheers!

    Read the article

  • jQuery UI Dialog adding unwanted inline styles to images

    - by oliver
    I am using JQUery UI to for the front end of a rails app I am developing. I am using jQuery dialog windows for displaying some tabbed data and inside one of these tabs I want to render some images. The rendering of the images works fine if I view the page without Javascript, however for some reason when putting it all in a dialog window all but the last image that I render gets some inline styles from somewhere! wihtout the dialog window: <img alt="Dsc_0085" class="picture" src="/system/sources/3/normal/DSC_0085.jpg?1260300748" /> <img alt="Dsc_0006" class="picture" src="/system/sources/4/normal/DSC_0006.jpg?1260301612" /> with the dialog window: <img alt="Dsc_0085" class="picture" src="/system/sources/3/normal/DSC_0085.jpg?1260300748" style="height: 0px; width: 0px; border-top-width: 1px; border-bottom-width: 1px; font-size: 22px; border-left-width: 1px; border-right-width: 1px; display: inline; "> <img alt="Dsc_0006" class="picture" src="/system/sources/4/normal/DSC_0006.jpg?1260301612" style="display: inline; "> I can't work out why putting the images into a dialog window is giving them inline styles with height and width of 0px, does anyone have any ideas?

    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

  • Getting value from href using jQuery

    - by bateman_ap
    Hi, I wonder if anyone can help with a jQuery problem I am having. I am using the tooltips from the Jquery Tools library to create a popup window when mousing over an hrefed image, this I want to use to cusomise the call to change the content in the DIV. The links I am using are in the form: <a href="/venue/1313.htm" class="quickView"><img src="/images/site/quickView83.png" alt="Quick View" width="83" height="20" /></a> The code I am using to trigger the tip is: $(".quickView").live('mouseover', function() { if (!$(this).data('init')) { $(this).data('init', true); ajax_quickView(); $(this).tooltip ({ /* tooltip configuration goes here */ tip: "#quickViewWindow", position: "right", offset: [0, -300], effect: 'slide' }); $(this).trigger('mouseover'); } }); I have tried the following function to grab the ID (in the example above, 1313) from the link: function ajax_quickView(){ var pageNum = $("a.quickView").attr("href").match(/venue/([0-9]+)/).htm[1]; $("#quickViewWindow").load("/quick-view/", function(){}) } However I think this is where it falls down, I think my regex is prob to blame... Once I get the var pageNum I presume I can just pass it into the .load as: $("#quickViewWindow").load("/quick-view/", {id : pageNum }, function(){}) Many thanks

    Read the article

  • How to submit the form using JQuery UI?

    - by Vafello
    I have a form in html with a default submit button. After the form is submitted, a php file is run (with action = homelocation). I decided to use JQuery UI dialog to display the form. I have 2 default buttons there - one to save and one to close the dialog. Can anyone tell me how to assign the form submit button action to the JQuery dialog button(i.e. replace the submit button from the form with the one in the dialog)? Here's my code: <div id="userdialog" title="Add"> <form id="add" action="engine.php" method="POST"> <input type="hidden" name="action" value="homelocation" id="action"> <button type="submit">Save this location</button> </form></div> Dialog: $('#userdialog').dialog({ width: 260, position: [250,100], buttons: { "Save": function() { HERE GOES THE REQUIRED FUNCTION $(this).dialog('close'); }, "Don't Save": function() { $(this).dialog("close"); } } });

    Read the article

  • Inserting an element within jQuery Validation plugin's error template

    - by simshaun
    I'm utilizing the jQuery Validation plugin for my form. It lets you change the errorElement and wrap the errorElement using with the wrapper option. But, I want to insert an element within errorElement like this: <label class="error"><em></em>Error message goes here</label> Is there an easy way to accomplish inserting the em tag? I've tried prepending the em tag using the errorPlacement option (see below), but it seems the plugin is replacing the contents of errorElement afterwards. $.validator.setDefaults({ errorPlacement: function(error, element) { error.prepend('<em/>'); error.insertBefore(element); } }); I've also tried prepending the em tag using the showErrors option (see below). Again, it seems the plugin is replacing the contents of errorElement afterwards. $.validator.setDefaults({ showErrors: function(errorMap, errorList) { for (var i = 0; i < errorList.length; i++) { var error = errorList[i], $label = this.errorsFor(error.element), $element = $(error.element); if ($label.length && $label.find('em').length == 0) { $label.prepend('<em/>'); } } this.defaultShowErrors(); } }); I've also tried modifying the plugin so that when the error element is generated, the <em> tag is prepended. That works until I focus on a form element that has an error, after which the em tag is removed. (It's doing this because jQuery validation is constantly updating the contents of the error element as I focus and/or type in the field, therefore erasing my em tag added at error-element creation.)

    Read the article

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