https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php contain the following code:
// Attach caption to document
JFactory::getDocument()->addScriptDeclaration(
"jQuery(window).on('load', function() {
new JCaption('" . $selector . "');
});"
);
but in https://github.com/joomla/joomla-cms/blob/staging/media/system/js/caption.js JCaption - now is function:
var JCaption = function(c) {
var e, b, a = function(f) {
e = jQuery.noConflict();
b = f;
e(b).each(function(g, h) {
d(h)
})
},
d = function(i) {
var h = e(i),
f = h.attr("title"),
j = h.attr("width") || i.width,
l = h.attr("align") || h.css("float") || i.style.styleFloat || "none",
g = e("<p/>", {
text: f,
"class": b.replace(".", "_")
}),
k = e("<div/>", {
"class": b.replace(".", "_") + " " + l,
css: {
"float": l,
width: j
}
});
h.before(k);
k.append(h);
if (f !== "") {
k.append(g)
}
};
a(c)
};
I expect to see class in caption.js or function call in behavior.php
As a result some functions doesn't work correctly. We have the following code:
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('a.menu_class3').click(function () {
$('ul.the_menu3').slideToggle('medium');
});
});
</script>
Now object $('ul.the_menu3') is null and we see error-message in browser developer console:
TypeError: $(...) is null.
When we replace older version of caption.js from Joomla 3.1.5 (where JCaption() - is class) all works correctly.
Title |
|
Title |
|
Title |
|
Title |
|
Title |
|
Title |
|
And you should not use $
globally.
The issue is invalid, from my point of view.
@Fedik Thank you for links, but I know about "new" operator usage for Function objects in JavaScript.
I'll try to replace code
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('a.menu_class3').click(function () {
$('ul.the_menu3').slideToggle('medium');
});
});
</script>
on
<script language="javascript" type="text/javascript">
jQuery(document).ready(function () {
jQuery('a.menu_class3').click(function () {
jQuery('ul.the_menu3').slideToggle('medium');
});
});
</script>
and situation changed. It seems to help solve my problem.
then please close the issue, because it not Joomla! issue
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-03-27 13:55:33 |
Closed_By | ⇒ | ivsero |
oh man, I just leave it here
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function