Click here to Skip to main content
11,721,385 members (80,233 online)

JavaScript

 
AnswerRe: generate random numbers from specific array Pin
John Y.19-Feb-13 5:47
memberJohn Y.19-Feb-13 5:47 
Questionaccess info popup page Pin
apadana_198928-Dec-12 6:58
memberapadana_198928-Dec-12 6:58 
AnswerRe: access info popup page Pin
Sandeep Mewara4-Jan-13 3:13
mvpSandeep Mewara4-Jan-13 3:13 
AnswerRe: access info popup page Pin
vinodkumarnie18-Jan-13 22:56
membervinodkumarnie18-Jan-13 22:56 
Questioncontrol other page Pin
apadana_198928-Dec-12 6:50
memberapadana_198928-Dec-12 6:50 
AnswerRe: control other page Pin
aeman29-Dec-12 22:34
memberaeman29-Dec-12 22:34 
AnswerRe: control other page Pin
jkirkerx31-Dec-12 10:34
memberjkirkerx31-Dec-12 10:34 
QuestionProblem With jQuery AppendTo and Data Attributes Pin
AnalogNerd28-Dec-12 3:41
memberAnalogNerd28-Dec-12 3:41 
I've run into a rather interesting, and frustrating bug that I'm hoping someone has some experience with or can help me work around.

Here's the scenario, and I've also set up a fiddle to show it [^]


I have a div with data-location="1"

If I move this div like this

$("#myDiv").appendTo("#someOtherDiv");

and then change the data-location value

$("#myDiv").data("location", "newValue");

I can no longer find the element using the data-location attribute.

This returns 0
$("[data-location='newValue']").length;

This returns 1
$("[data-location='oldValue']").length;

BUT, this returns newValue
$("#myDiv").data("location");

Has anyone ever run into this? Am I missing something here, or doing something wrong?

[EDIT: has some trouble with the fiddle, the link works now.]

[EDIT: SOLVED]
Apparently the .data in jquery only reads the attributes once and never sets the attributes. If you want to set data- attributes and recall them in your code you have to use the .attr() call.

modified 28-Dec-12 10:51am.

Questioncss Pin
SINNAM28-Dec-12 1:32
memberSINNAM28-Dec-12 1:32 
AnswerRe: css Pin
Keith Barrow28-Dec-12 2:33
mentorKeith Barrow28-Dec-12 2:33 
Questioncss Pin
SINNAM28-Dec-12 1:29
memberSINNAM28-Dec-12 1:29 
AnswerRe: css Pin
Sandeep Mewara4-Jan-13 3:14
mvpSandeep Mewara4-Jan-13 3:14 
AnswerFB Connect Javascript Pin
sasikumar.prs26-Dec-12 23:29
membersasikumar.prs26-Dec-12 23:29 
GeneralRe: FB Connect Javascript Pin
khiladi78631-Dec-12 5:40
memberkhiladi78631-Dec-12 5:40 
GeneralRe: FB Connect Javascript Pin
jkirkerx31-Dec-12 10:36
memberjkirkerx31-Dec-12 10:36 
AnswerRe: FB Connect Javascript Pin
Sandeep Mewara4-Jan-13 3:17
mvpSandeep Mewara4-Jan-13 3:17 
QuestionGridview Problem Pin
jojoba201122-Dec-12 5:05
memberjojoba201122-Dec-12 5:05 
AnswerRe: Gridview Problem Pin
Sandeep Mewara4-Jan-13 3:25
mvpSandeep Mewara4-Jan-13 3:25 
Questionxna4life Member 13 Points 71 Posts hard code drop down instead of using toolbar and r/s Pin
xnaLearner21-Dec-12 3:34
memberxnaLearner21-Dec-12 3:34 
Questioni m using google map its giving little bit problem. Pin
kapil sharma 4920-Dec-12 23:52
memberkapil sharma 4920-Dec-12 23:52 
AnswerRe: i m using google map its giving little bit problem. Pin
Sandeep Mewara4-Jan-13 3:31
mvpSandeep Mewara4-Jan-13 3:31 
Question"&nbsp" problem in Javascript Pin
BrianCampbellMCAD20-Dec-12 12:08
memberBrianCampbellMCAD20-Dec-12 12:08 
QuestionRe: "&nbsp" problem in Javascript Pin
Richard MacCutchan20-Dec-12 23:00
mvpRichard MacCutchan20-Dec-12 23:00 
AnswerRe: "&nbsp" problem in Javascript Pin
BrianCampbellMCAD21-Dec-12 1:42
memberBrianCampbellMCAD21-Dec-12 1:42 
GeneralRe: "&nbsp" problem in Javascript Pin
Richard MacCutchan21-Dec-12 2:06
mvpRichard MacCutchan21-Dec-12 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.150901.1 | Last Updated 4 Sep 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid