JQuery :: Setting Up A Bunch Of Listeners With A Looping Structure
Apr 30, 2010
I'm trying to come up with a better architecture for dealing with multiple listeners in a multi-page questionnaire. Here's the general structure I'm looking to implement:
1. Set up CSS for animation
2. Look for preconditions
3. Initialize listener
4. Execute animation
Some issues to consider:
1. Some questions have dependencies that show or hide depending on what is selected in a parent question.
2. Needs to be IE 6 compatible.
3. It should be simple enough so that all you need to do is add a new question to a JSON object, which is what I have set up right now.
Some code (the looping structure that reads each question):
var newQ = eval(q);
$.each(newQ, function () {
// 1 - Setting CSS for each listener
$(this.css).css({'width': '1500px', 'float': 'left', 'clear':'both'});
[Code].....
The problem here is that when I do a console.dir on $.each(this.value.length), it counts each character, as opposed to counting the number of elements in the array. Should I be doing an eval on q? Why or why not? If I could get this up and running, it would make my life 100x easier, as there are hundreds of questions, and I'd want to make this all data driven.
View 10 Replies
ADVERTISEMENT
Apr 23, 2010
I have a quandary of sorts here dealing with a list of checkboxes and the hiding/showing of a few divs associated with the checkbox selection. Here's basically what I need to do: Hide the lower div if no checkbox is selected. If any one of the first 6 checkboxes are selected, and NOT any of the remaining 6, then show the div. If at any time during selection one of the remaining 6 checkboxes are selected, then hide the associated div. Note this code doesn't really do much. I'm still trying to architect a solution that's best.
var aThroughf = false;
var gThroughl = false;
$('[name="'+q2030.name+'"]')).live('click', function() {
[code]....
View 16 Replies
View Related
Jan 9, 2010
I'm using this piece of code to find a set of selected check boxes that are selected abd build a comma separated list from their values
'txt' custom attribute
. Is this a jQuery standard method?
e.g
<input type="checkbox" id="chkGenre" rel="genre" value="12"
txt="Rock" /> <br />
<input type="checkbox" id="chkGenre rel="genre" value="13" txt="Jazz" /
View 5 Replies
View Related
Jun 16, 2011
I really don't know how to explain this well.
[Code]...
So when a user goes to that directly, all the presets are already there? (since my updateResults function already sends that data along when the user is actually using the page, perhaps I could just somehow parse that url and call my updateResults function with the requested parameters...
View 4 Replies
View Related
Apr 4, 2010
I tried to enumerate through a index array to assign different ids to newly retrieved JSON data, the li element is initially set to be hidden and the hidden data can be seen from console. But the browser is failing to show the data when I tried to use ('li#a').animate({opacity: "show"}, "slow"); I also tried to use .animate right after each <li> appendTo the body and failed to show as well. I am wondering how to fix this? Is there any better way of handling this with out creating an enumerating array?
View 1 Replies
View Related
Sep 20, 2009
I've cobbled this script together to help me implement 'read more.[URL]... It does the job, but I lose all the mark-up in the process :[ It doesn't cater for a bunch of tags like <img>, <ol>, <ul> etc. slice()
ain't being too kind to me. // create a 'read more' link, and hide remaining text, if post content
[Code]...
View 1 Replies
View Related
Aug 2, 2011
I know this isn't a jQuery question per se, but maybe there is an easier way to do this is jQuery than in javascript?
<script>
I was wondering if there is a better way to accomplish the above? Rather than directly changing the innerHTML of the element is it possible to add a onclick listener (or another javascript listener) to the element in a more direct way without having to go through the html.
View 1 Replies
View Related
Sep 15, 2010
I have taken over from a developer who has used javascript to add additional text input boxes to a form so there is no limit to the number of input boxes there can be. I have got a jquery autocomplete function that works fine if the input box is added by the server but the listener doesnt fire when the text box is added client side. As with all things this is part of a much bigger project and I only want to change the smallest possible part (add autocomplete to this text input box) MY QUESTION: is it even possible fo ra jquery listener to fire when the input box has been written client side after the page has loaded? Is there a way to "refresh" a listenerto find the new tag that have been added?
View 2 Replies
View Related
Aug 20, 2011
I'm not sure if I'm calling it the right thing, but I'm trying to dynamically create a bunch of key => value pairs in a javascript object.
Something like this:
Code JavaScript:
But the console gives me errors, and I haven't been able to find a way to do this. I've tryed putting the keys in square brackets, as was suggested somewhere online, but that didn't work.
View 2 Replies
View Related
Apr 28, 2011
Here's what I'd like to do using pure JavaScript and HTML (no Ajax or PHP): My website loads different JavaScript files dynamically which contain a bunch of data, that I will display on the website. The dynamical loading function is placed in the <HEAD> and looks like that:
Code:
function loadJsFile(filename){
console.log("loading js file")
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
fileref.onload = dataIsLoaded;
if (typeof fileref!="undefined"){
document.getElementsByTagName("head")[0].appendChild(fileref)
}}
The dataIsLoaded method in there is a callback that is triggered when the JavaScript file has been loaded:
Code:
function dataIsLoaded(){
console.log("loading js file done")
dataLoaded = true;
data = new Data();
}
DataLoaded is simply a global boolean that is per default false and the 'data' variable contains all the data I want to display on my site. While the JavaScript file is being loaded, the browser continues building the site. When it gets to the <body> that wants to access some information from the data variable, I get the unsurprising error that 'data' is undefined. I looked for a way to wait until 'data' is defined and then continue with building the <body> but couldn't find a solution.
Alternatively I wanted to reload the divs in the <body> when the 'data' is available:
Code:
function reloadDivs(){
if(dataLoaded){
console.log("data available, reloading divs");
document.getElementById('someDiv').innerHTML = document.getElementById('someDiv').innerHTML
}else{
console.log("data is not yet available");
setTimeout('loadReportData();', 500);
}}
This does not work, I get a blank div when I do that.
View 10 Replies
View Related
Oct 15, 2010
Does anyone know of a script or has a script i could use that allows me to load a bunch of images and display only a range of them on a certain page?
View 5 Replies
View Related
Jan 3, 2012
I have a nested listview in my app which creates table inside table at runtimei need to get value of td from second tables tr where i have row number of first tables tr?
<listview1>
View 6 Replies
View Related
Jul 30, 2010
Is it possible to change a document structure definitely using JQuery ? I used .html() but after refreshing the page the changes I've done disappeared and were replaced by the default contents
View 2 Replies
View Related
Jul 31, 2009
In my application, there is a view page to show the table of Attributes name as the header and its value filled by many people below. [code]...
View 3 Replies
View Related
Nov 21, 2011
I'm having two issues: First, is there an easier way for my showValue function to display the image file name without running a bunch of if statements? I tried doing something like document.getElementById('imgFile').value = imgArray[n]; but that did not seem to work.
Second, I'm trying to have the image file name change in my textbox when I click any button. I've accomplished this with onblur, but that only works if I click on the textbox. I'd like it to just change automatically.
[Code]...
View 5 Replies
View Related
Apr 26, 2009
I have a string that is like [{"carePacks":
[{"businessCode":"J1PS","description":"HP 1"}],"coveragePeriod":12},
{"carePacks":[{"businessCode":"J1PS",
"description":"HP s"}],"coveragePeriod":13}].
How to convert it to a json structure and how to get data from the data structure, like get "HP 1".
View 2 Replies
View Related
Jun 11, 2009
Given the following structure:
<div id="section_list">
<ul>
<li></li>
<li>
[Code].....
Not only does it look hacky, but it's giving me obviously bad results. To complicate things further, I'm using MPTT for my tree data, so sortable's serialize isn't much help, unfortunately. I originally thought I might figure out the parent_id, lft, and rght values upon sort but that would entail storing all that data somewhere in the DOM. I then realized that, if I can just get the number of positions moved, I could update the DB with that information.
View 2 Replies
View Related
Feb 22, 2011
I have the following data structure (shown in code view below) coming back from a query. How can I loop over this and create an <li></li> for each record on the client side?The end result should be :
<li><a href="page.htm?id=1
">Kate
</a></li>
[code]....
View 1 Replies
View Related
Mar 1, 2011
I have a JSON data structure that I'm pulling in VIA an AJAX call. What I want to be able to do is click a button/link and be able to save this data structure to disk, but I'm not really sure how to go about this. I've been experimenting with the following:The link has the following format "<a href='data:application/json, " + data_structure + "'>Click here!</a>" I've been able to replace data_structure with text and /json to /rtf, which gives me a pop-up 'SaveAs' dialog box, and when I open the file, it has my text in there. However, if I do data_structure, I just get [Objectobject], which is telling me that I'm passing in the object, but that's basically it, I need to expand it out? I'm not really sure how to do that...Which leads me to calling a perl script. So I make an ajax call like so:
$.ajax({
'dataType': 'JSON',
'type': 'GET',
[code]....
View 1 Replies
View Related
May 14, 2010
This is my table structure, I want to find out the index of the tr which first td is empty, in this case, the index should be 1, how to pick it out?
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr><td>1</td>
<td>1</td>
<td>1</td>
<td></td></tr>
<tr><td></td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr><tr>
<td>2</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr><tr>
<td></td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr></table>
View 1 Replies
View Related
Mar 9, 2010
I want to build something like a foldable tree using Jquery. But the problem is I am getting the values from a Database.My database structure is
ID--PID----NAME---------NUMBER---------ROLE
-------------------------------------------------------------
1--0---------John----------1234-------------Manager
[code]....
View 4 Replies
View Related
May 31, 2011
I'm trying to make an accordion structure, load dinamically content. This what i done, and that's work, but now i need to improve it.
Here the css
<style>
.project { display:none; }
</style>
<div id="project-box">
[Code].....
View 2 Replies
View Related
Jul 21, 2010
I am trying to select (and then clone) an entire DOM structure excluding one div.
The DOM is stored in a variable like this: var original = $(this).closest("table.mainContainer");
The I try to exclude the div in the clone like this $(original).find(":not(div.container)").clone();
But the div is shows in the clone.
View 10 Replies
View Related
Sep 23, 2011
Is it possible create a tree structure with 20000 nodes and it should load fast.
View 5 Replies
View Related
Dec 1, 2009
I want to accomplish a nice and simple accordion menu using this HTML structure:
Code HTML4Strict:
And I'm using this JQuery code:
Code JavaScript:
This basically works, but when I click a particular menu item to expand it's submenu items, it basically hides all submenus items, even the active ones, but whant I need is the particular clicked submenu items to stay expanded. I guess this can be accomplished by a simple if statement or so.
View 3 Replies
View Related
Sep 27, 2011
I feel like I must be missing something simple but I can't put my finger on it...
I'm moderately new to JS (programmed in other languages though) and am working on a Google Maps project.
This piece of code should show an alert of the region's name when a map polygon is clicked. Instead, no matter what polygon is clicked, it only does the name for the LAST iterated placemark. code...
What am I missing? What would be a better way of handling this?
View 5 Replies
View Related