a JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
4
votes
4answers
182 views
JavaScript: How to provide one-time calculations to frequently used methods
I'm new to JS/JQuery and wrote some JavaScript/JQuery lines to create a "pulsating" object.
I get the "pulse" effect by increasing/resizing the object and then bringing it back to its original state ...
2
votes
0answers
34 views
$.fn.do() method: Execute other code within a jQuery chain
What I want to do is; without leaving the chain, execute some custom/external code (and continue) within the chain. Otherwise; in a deep chain, I will have to re-query for the DOM element to get back ...
2
votes
2answers
62 views
Clean up jQuery script
I combined multiple jQuery scripts into one script. This script converts a <ul> element to a <select> box (for use in Response WebDesign). But I think this script is not well written, can ...
3
votes
1answer
47 views
Writing A Better/Cleaner if statement
This piece of code I have written works, but I don't think its the best solution.
What I am doing is check if a certain radio is checked if it is show this div if else show this div if this radio is ...
2
votes
2answers
53 views
Better way to filter select list
I'm brand new to javascript and jquery and I feel like there's probably a better way to do this. It seems that the way I designed it may not be very optimal once you get a thousand entries in the list ...
2
votes
1answer
36 views
Edit/Details form in JavaScript
I have a Edit/Details form which has 4 user related fields. On click of Save, I save the edited fields to local storage (if supported) and display the same values in the Details view.
Below is the ...
0
votes
0answers
35 views
JS simple cache mechanism?
In my system I frequently require data by Ajax requests. For example, different lists, content of modal dialogs, etc. This data can't be changed after request, so I wrote cache mechanism which stores ...
3
votes
1answer
54 views
jQuery Object Oriented Plugin
After seeing a lot of Paginator plugin that never fit my needs, I've decided to create my own. I have followed the jQuery Authoring advices.
Configuration prerequisites:
The plugin CSS have to be ...
2
votes
1answer
37 views
Simple JS/jQuery notification system
I'm new to front-end development and now I'm learning JavaScript with jQuery.
I couldn't understand JavaScript's classes and objects and jQuery plugins, but after reading some articles and examples I ...
2
votes
1answer
35 views
Dynamically mess images inside a container
Well, i'm starting a function to 'mess' with a image gallery, i made an example
i wanna know if the way i'm doing is realy the BEST way, the function work perfect, but i fill that can be better, ...
1
vote
2answers
52 views
Reduce JavaScript code. Double event, selector into one
Any idea how to write this code better."the html is nested tabs"
Two selectors and two similar events, in a function would be better or a pattern to reduce lines. eg .jsbin
$(function() {
var ...
1
vote
1answer
32 views
How Can I Improve my Image Preloading Script?
I wrote an infinite scrolling scrolling plugin for an app I'm developing. When requesting the second 'page' from the server, I loop through each image, and five it a very basic onload function.
// I ...
2
votes
1answer
25 views
Convert javascript to css media query?
I'm running into page performace issues and I believe this block is causing the biggest slowdown:
// Section menu on mouseover, hide menu on mouseout
// Can be more concise using .toggleClass?
...
1
vote
1answer
34 views
jQuery simplify multiple and similar numbered functions
Those functions are selected by the same index, I understand the index logic of what to do but I don't know how to do it well enough. Please give me a hand!
// those are buttons that will ...
4
votes
1answer
141 views
How can I have coded this better so my code doesn't look so amateurish?
This code takes 8 divs and races them across the screen depending on which time value the div was assigned. How can I have coded this better so my code doesn't look so amateurish?
I know I should ...
2
votes
1answer
48 views
How can I improve performance of my selecting code
I have a page with a list of items. Items have several actions assigned to them. (see screenshot).
One may choose to directly click on an icon next to each row or check a checkbox on the left hand ...
3
votes
2answers
41 views
How can I improve jquery selectors of checkboxes
I need to select all checked checkboxes, except checkboxes having a class ".checkall".
HTML:
<input type="checkbox" value="1961" class="checkbox">
<input type="checkbox" name="checkall" ...
2
votes
1answer
41 views
How can I make this jQuery more object oriented or reusable?
I wrote this code to allow users to select multiple images, and each image can be selected multiple times.
It feels convoluted, though, and prone to errors. Like forgetting to do something associated ...
2
votes
1answer
31 views
Multi jQuery Sliders, Help me write this in better code
I have three sliders with different min, max values, everything is working fine from following the tutorials on the jQuery UI website.
$("#yield").slider({
range: true,
min: 15.2,
max: ...
2
votes
1answer
54 views
Underscore and general app design review
I'm working on my larger project to date, and on top of that I'm using underscore for the first time.
All is working perfectly but I'd like some criticism on the use of underscore templating and ...
1
vote
1answer
30 views
JQuery Dynamic Dropdown Update
This is based (somewhat loosely) on the code written in this railscast. I'm planning to re-use it in different places throughout the site, so I made it a bit more generic rather than based on IDs. ...
4
votes
1answer
66 views
Is there a more efficient way to code this “Item-picker”?
I would love to show you one of my bigger scripts to improve my technique.
This script is some kind of Itempicker. You choose your Item first (toprow), then pick a color. The color of the active Item ...
2
votes
2answers
50 views
Form Validation (JQuery)
I made a simple form validation. It's working alright. The thing is I want my code to be optimized. Can somebody show me some pointers to improve my code? Thanks in advance.
...
3
votes
2answers
72 views
If statement, is the shortened version readable enough?
I have to perform an IF statement in my Javascript code. I utilised the first method shown below:
(someVar1 !== "someString") && (someVar2[i].disabled = (someVar3.find("." + someVar4).length ...
4
votes
1answer
50 views
Is there a better way to write my jQuery slider?
First question here so please be gentle. I have developed a jQuery slider and I want to implement it in WordPress (it will be a Featured posts slider).
This is my slider logic:
If there are 1 or 3 ...
1
vote
1answer
34 views
jQuery, Two click functions doing the same thing, only difference is the selector. Is there a better way to do this?
I have the following jQuery click functions:
$childCheckbox.click(function(){
if(!$(this).hasClass('checked') && !$parentCheckbox.hasClass('checked')){
...
3
votes
1answer
64 views
Optimize jQuery Iteration
I have a list of elements (well, nested lists of elements, really) that the user can reorder (using jQuery sortable()). A simplified view of the structure is something like:
<div ...
3
votes
2answers
56 views
Help with jquery form data code refinement
Could someone please help me make this code as professional as it can be? It works fine, it's just I look at it and think, 'there is surely a better way to do some of this', I would really appreciate ...
1
vote
0answers
39 views
JQuery Drag Div Code Simplification
My code allows for the user to move a div around a container div by clicking and dragging the top, much like a window on a desktop. It does this by waiting for mousedown then mousemove, getting ...
2
votes
1answer
69 views
Can I use jQuery's .when() to make this code DRY?
I'm trying to run a bit of code when my loginManager is logged in. It might be already, or I might be waiting:
var loginManager = chrome.extension.getBackgroundPage().LoginManager;
// If the ...
2
votes
0answers
45 views
jQuery plugin boilerplate jquib - critics please
Inspired by jqueryboilerplate.com I extended their boilerplate to fit my needs. Comming from the PHP development I wanted to have good starting point for writing jQuery plugins with a defined ...
2
votes
0answers
16 views
Ideas on how to improve table plugin
Took me a while(attempts) to get this working exactly how I want but I thought I would post it here for suggestions to improvements(performance/accessibility).
$('table').each(function(){
var ...
2
votes
0answers
32 views
Stripping formatting from text - Am I using an efficient jQuery selector?
I'm making a comment box using a contenteditable div, but I want to remove formatting from text a user might copy/paste into it (also no CTRL+B or CTRL+I shortcuts allowed either). Only "approved" ...
1
vote
0answers
59 views
jQuery plugin for easy CSS3 transformation
I wrote it more for educational reasons and less as something that can compete with existing alternatives.
But I enjoyed writing it and wish to get some feedback, JavaScript is my second language :)
...
-1
votes
1answer
45 views
Trouble with jquery show and hide [closed]
I'm having a ton of trouble trying to get simple jquery functionality to work. All I want is to be able to click on a menu button and have a menu pop up and click outside of it to close it. I think ...
1
vote
0answers
35 views
Creating and referencing markup…cloning, etc. efficient system for this plugin
I am pulling multiple feeds from youtube that have a callback function which makes markup from each feed. They add that markup to a documentFragment stored in var data. When all the feeds have ...
0
votes
2answers
71 views
AJAX response DOM element selection
I GET a HTML response from AJAX over cors and the response is a table. Each category has its title and sub elements. The title names vary quite a bit and are likely to change in the future. The sub ...
0
votes
1answer
36 views
Optimizing a jquery user interface application
I'm working on a javascript intensive user-interface application. (At least it's intensive for me, it's my first serious javascript project).
I have a few jquery functions going whenever a div is ...
-1
votes
0answers
62 views
I found the piece of code that made my javascript run slow. How do I optimize it to run faster? [closed]
According to jsHint it should work fine however my website literally cannot load with this code in my javascript.js file. I've fixed all that I could think of is there anything else? Sorry, it's a bit ...
1
vote
2answers
73 views
jQuery code refactoring
Just wanted some opinions on how to write this code a little better, it is working properly, I'm just trying to learn how to write jQuery better so I wanted some smart peoples opinions. Thanks!
It is ...
3
votes
2answers
76 views
Replacing text in an array
I have this piece of code to replace current text inside an array of html divs with values coming from a JSON file:
$.each($('.something'), function(){
if($(this).text()=="1"){
...
4
votes
1answer
44 views
Looping through Radgrid in JS is slow, can this be faster?
I do a single select in one radgrid, and based upon that selection I want to select multiple rows in a different radgrid:
<telerik:RadGrid ID="rgPaymentLines"> <ClientEvents ...
3
votes
1answer
92 views
JS/Jquery newbie here… Can I please get some advice on improving my code?
You can see the JS at the end of this post in action here at http://andrew-oh.com/portfolio/timeline/ (It's responsive!)
I've recently picked up javascript/jquery and would love some feedback on how ...
1
vote
1answer
26 views
Simplify jQuery animation with callback
Looking for feedback on how to better improve the code below to simplify the code below.
var animateTop = $('body');
if ($('html').hasClass('lt-ie9')) {
animateTop = $('html');
}
...
1
vote
3answers
61 views
Nested if nightmare, there has to be a better way
There has to be a better way of checking on variables than this nightmare of ifs. It works, but I don't think it's good code at ALL.
My HTML has three divs, each id tagged with the logic behind my ...
3
votes
1answer
101 views
Filtering and Sorting jQuery Ajax response
What I'm trying to accomplish here is to pull a table of open employment positions with AJAX, filter out the garbage code that comes with it, put each <tr> from the response into its correct ...
2
votes
1answer
37 views
Optimize Clock Update Code To Prevent Bottleneck Resulting In Time Lost
I use the following PHP Code to output the user's local time and the servers time (office time). $local_time and $remote_time are the corresponding UNIX timestamps:
<span class='icon-time' ...
2
votes
3answers
96 views
jQuery: Optimize code - add/remove class to label tags
I'm not a jQuery guru, so that's why I'm asking for guidance.
I came up with this jQuery snippet to add/remove a class on <label> tags that contain either checkboxes or radio buttons in order ...
-1
votes
1answer
41 views
How to organise jquery code and avoid events to fire on every page [closed]
I discoverd my jquery code is a mess, right now it doesnt follow any type of logic build up. I have lots of ajax calls, nested functions, dom manipulations, plugin calls in my main js file.
Lot of ...
4
votes
1answer
63 views
Improving logic for pulling and passing data();
I'm pulling data from a list of images and passing it into an information container after click. After looking at my logic I assume there is a better way to do this. Any ideas would be helpful.
var ...