Click here to Skip to main content
15,918,976 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Browser Back Button Pin
Keith Barrow8-Jan-13 1:41
professionalKeith Barrow8-Jan-13 1:41 
AnswerRe: Browser Back Button Pin
Sandeep Mewara4-Jan-13 2:55
mveSandeep Mewara4-Jan-13 2:55 
AnswerRe: Browser Back Button Pin
twseitex8-Jan-13 6:56
twseitex8-Jan-13 6:56 
AnswerRe: Browser Back Button Pin
Anjum.Rizwi15-Jan-13 21:20
professionalAnjum.Rizwi15-Jan-13 21:20 
AnswerRe: Browser Back Button Pin
vinodkumarnie18-Jan-13 22:33
vinodkumarnie18-Jan-13 22:33 
AnswerRe: Browser Back Button Pin
Deepak Kr17-Feb-13 22:26
Deepak Kr17-Feb-13 22:26 
Generalhow can we set random image in my asp website? Pin
GDdixit31-Dec-12 5:43
GDdixit31-Dec-12 5:43 
AnswerRe: how can we set random image in my asp website? Pin
Sandeep Mewara4-Jan-13 2:59
mveSandeep Mewara4-Jan-13 2:59 
GeneralRe: how can we set random image in my asp website? Pin
GDdixit22-Jan-13 0:52
GDdixit22-Jan-13 0:52 
GeneralRe: how can we set random image in my asp website? Pin
Sandeep Mewara22-Jan-13 2:34
mveSandeep Mewara22-Jan-13 2:34 
Questiongenerate random numbers from specific array Pin
aeman29-Dec-12 22:16
aeman29-Dec-12 22:16 
AnswerRe: generate random numbers from specific array Pin
Sandeep Mewara4-Jan-13 3:06
mveSandeep Mewara4-Jan-13 3:06 
AnswerRe: generate random numbers from specific array Pin
Joe DiNatale4-Jan-13 9:28
Joe DiNatale4-Jan-13 9:28 
AnswerRe: generate random numbers from specific array Pin
John Y.19-Feb-13 5:47
John Y.19-Feb-13 5:47 
Questionaccess info popup page Pin
apadana_198928-Dec-12 6:58
apadana_198928-Dec-12 6:58 
AnswerRe: access info popup page Pin
Sandeep Mewara4-Jan-13 3:13
mveSandeep Mewara4-Jan-13 3:13 
AnswerRe: access info popup page Pin
vinodkumarnie18-Jan-13 22:56
vinodkumarnie18-Jan-13 22:56 
Questioncontrol other page Pin
apadana_198928-Dec-12 6:50
apadana_198928-Dec-12 6:50 
AnswerRe: control other page Pin
aeman29-Dec-12 22:34
aeman29-Dec-12 22:34 
AnswerRe: control other page Pin
jkirkerx31-Dec-12 10:34
professionaljkirkerx31-Dec-12 10:34 
QuestionProblem With jQuery AppendTo and Data Attributes Pin
AnalogNerd28-Dec-12 3:41
AnalogNerd28-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

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


and then change the data-location value

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


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

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


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


BUT, this returns newValue
JavaScript
$("#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
SINNAM28-Dec-12 1:32 
AnswerRe: css Pin
Keith Barrow28-Dec-12 2:33
professionalKeith Barrow28-Dec-12 2:33 
Questioncss Pin
SINNAM28-Dec-12 1:29
SINNAM28-Dec-12 1:29 
AnswerRe: css Pin
Sandeep Mewara4-Jan-13 3:14
mveSandeep Mewara4-Jan-13 3:14 

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

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