问题描述:

Suppose there is a web application that has the following application.js.

$(function () {

$('#element').data('hello', 'itsme');

});

The web application is deployed, and from browser console doing

$('#element').data('hello')

returns itsme as expected.

However, from local development environment (i.e. http://localhost.com/example), doing the exactly the same thing returns undefined.

Is there something I am missing about jQuery data?


The exact situation:

This is my deployed module: https://togetherjs.com/examples/youtube/

From console, you can get the player object like below

var f = $('iframe')[0];

var player = $(f).data('togetherjs-player')

Doing exactly the same thing in local development environment, I get player == undefined.

What could be a possible reason?

相关阅读:
Top