Loading...
Copy code
Close
Permalink
Close
Please tell us why you want to mark the subject as inappropriate.
(Maximum 200 characters)
Report Inappropriate
Cancel
Private Message
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Cancel
From :
guest
To :
Subject :
Content :
Type the characters you see in the picture below.
Send
Update
Cancel
Feedback
Email ID
Subject :
Comments :
Send
Cancel
Private Message
Type the characters you see in the picture below.
Type the characters you see in the picture below.
Attach files
Desktop
Zoho Docs
Google Docs
Each Attachment size should not exceed 1MB.
Max no of attachments : 3
Loading User Profile...
guest
Response title
This is preview!
Attachments
Publish
Back to edit
Cancel
(
)
Sign In
New to this Portal? Click here to
Sign up
You can also use the below options to login
Login with Facebook
Login with Google
Login with Yahoo
jQuery
Plugins
UI
Meetups
Forum
Blog
About
Donate
All Forums
Recent Posts
Log In
Search
jQuery
Search
jQuery Forum
Screen name:
brunovinny
brunovinny's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Ideas
Problems
Expanded view
List view
Private Message
Problem with multidimensional response
[0Replies]
17-Jan-2013 10:08 AM
Forum:
Using jQuery UI
/* I have an json query that returns: */
/*
?(
[
{
label
:
"Thomas"
,
value
:
"Thomas"
,
id
:
"34"
},
{
label
:
"Tiesto"
,
value
:
"Tiesto"
,
id
:
"12"
}
]
)
*/
/*
I'm trying to get the response's "id" field value, but jquery always returns the label field value or an empty value. How do I to get this third? I want to get it and add it to a <span> who will have "id" field with the response's "id" value inside.
*/
$(function(){
//attach autocomplete
$("#adicionaEventoAtracaoWarmup").autocomplete({
//define callback to format results
source: function(req, add){
//pass request to server
$.getJSON("evento/processa.php?acao=buscarAtracao&callback=?", req, function(data) {
//create array for response objects
var suggestions = [];
//process response
$.each(data, function(i, val){
suggestions.push(val.label);
});
//pass array to callback
add(suggestions);
});
},
//define select handler
select: function(e, ui) {
//create formatted friend
var atracao = ui.item,
// HERE IS THE PROBLEM... TRYING TO ADD THE ID ATTR I'M ALWAYS GETTING THE LABEL OU AN EMPTY VALUE
span = $("<span>").text(atracao.label).attr({id: atracao.id}),
a = $("<a>").addClass("remove").attr({
href: "javascript:",
title: "Remover " + atracao,
}).text("x").appendTo(span);
//add atracao to atracao div
span.insertBefore("#adicionaEventoAtracaoWarmup");
$("#adicionaEventoAtracaoWarmup").text("");
},
//define select handler
change: function() {
//prevent 'to' field being updated and correct position
$("#adicionaEventoAtracaoWarmup").val("").css("top", 2);
}
});
});
«Prev
Next »
Moderate user : brunovinny
Forum