a JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
2
votes
1answer
32 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
27 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
53 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
29 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
57 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
47 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
42 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
63 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
37 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
66 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
39 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
29 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
58 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
44 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
33 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
62 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
34 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
60 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
72 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
74 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
41 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
71 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/testpage/ (It's responsive!)
I've recently picked up javascript/jquery and would love some feedback on how I'm ...
1
vote
1answer
25 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
55 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
80 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
34 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
91 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
40 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 ...
0
votes
0answers
17 views
Trying to test my object's ability to save. It has some dependencies on a parent, though. Which test suite should be responsible?
I have an object of type PlaylistItem. In the 'real application', a PlaylistItem will always be added to a Playlist before saving.
However, I am trying to use Jasmine to test my PlaylistItem's save ...
2
votes
2answers
59 views
Optimized jquery code check
I am new to jquery, and after spending weeks to convert my pages using jquery, now I am reading about jquery optimization. In that effort, I rewrite one of my functions like below. Appreciate if you ...
2
votes
2answers
32 views
Maintain sync of select list
My objective has been to build a custom dropdown like the one on Amazon's search scope selector. I do this by positioning a styleable element on top of a standard select list. I then use jQuery to ...
0
votes
0answers
28 views
modal window with form
First, Sorry for my English.
I'm very new in web development. I want that you make code review of my code.
I have profile page where contains two tabs:User Info and Violations. In the User Info tab ...
0
votes
0answers
93 views
I implemented a User model with BackboneJS and RequireJS with test cases in Jasmine. How can I improve?
I've been taking a stab at implementing test cases using the Jasmine testing framework. To do so, I've made an application which has a User object. This User object is created by the server, but its ...
0
votes
1answer
44 views
Is it possible to simplify my AJAX navigation code?
I'm still learning javascript and I'm building an ajax website that loads in content for each page from external files (e.g. test1.php, test2.php). I spent several hours cobbling together some code ...
2
votes
3answers
110 views
How to Make This JavaScript Snippet DRY (Don't Repeat Yourself)?
I have the following JavaScript function:
function registerEvents() {
var isTapholding = false;
$(document).delegate('.add-control .add-image', 'tap', function (evt) {
...
0
votes
2answers
33 views
Different Function Test result Inquiry
I accidently made a post on StackOverflow, I'm new and wasn't intentional. I got redirected here. One person mentioned that the below test is not right because i'm using the scroll method and the way ...
2
votes
1answer
65 views
I've embedded several PHP/HTML/Javascript in one page. How can I improve on the efficiency/performance?
Just a quick preface, I'm not a web developer. I'm simply doing this as a favor for a friend. My goal is to be done with it as quickly as possible, but still not have the coding be horrendous. With ...
1
vote
2answers
87 views
Calendar code review
I wrote the following in Javascript and jQuery, and I'm wondering if there are any ways to improve the code, organize it better, and increase speed:
function calendar(d) {
...
-1
votes
1answer
80 views
Why I need to use 2 functions, but not only one [closed]
I paste all of my code because it might have a connection with the function I am asking for.
I had some problems with my parseJSON() function and someone helped me to make it work. Now I don't know ...
0
votes
1answer
67 views
Authentication system using AJAX
I'm building an authentication system using a combination of PHP, MySQL, jQuery, and AJAX. The way I'm doing it right now is I have a form that takes in a username and password. When the user clicks ...
3
votes
1answer
207 views
Improve Syntax & Structure
I'm building a small web application and it's starting to get a bit complex. I have reached to a point where I have to run some tests and load some libraries.
I made it so I can use it in this way :
...
1
vote
0answers
42 views
A custom jquery validate error message function
We have a rule that all of our validation messages must be in a summary, and thus the default "this field is required" doesn't cut it because the messages lose their context in a summary and therefore ...
1
vote
0answers
95 views
How to write a better code for validating Credit Card
I'm a beginner to the Javascript world. I recently created an extension which detects the type of credit card based on the numbers entered in and formats it. I am using Luhn Algorithm for validating ...
1
vote
1answer
27 views
Newbie jQuery code refactoring question
New to the whole jQuery malarky, but having a lot of fun with it. I was wondering if there was a way to rewrite this to be a bit more...clean? It seems a bit odd to have a mouseenter and a mouseleave ...
4
votes
1answer
91 views
This blueprint has already become a mess, please suggest some restructuring
I'm particularly concerned about where I have declared the functions, can I move them around to clean up the code without breaking anything? The "conjugate" function contains a lot of stuff that has ...