JQuery selector for href - jquery-selectors

I was using with jquery version 1.8.2
var hasContainerTab = $("#tabs").find("a[href='#container'").length == 1;
I upgraded jquery to 1.12.4. Now that statement is failing saying
unrecognized expression: a[href='#container'
I referred different blogs like (https://github.com/jquery/jquery/issues/2829) around this, but I could not find a fix.
Can any one tell me how to re-write the statement as per the new version?

Your selector is incorrect, since it misses the closing bracket ]. Use:
var hasContainerTab = $("#tabs").find("a[href='#container']").length == 1;

Related

How to replace deprecated SOBE Code in TYPO3 10.4

I inherited an old TYPO3 Extension using SOBE. As far as I unterstand it's deprecated, but it seems there is no documentation on how to replace it.
The Extension is using Backend Forms and the following line is throwing an error:
if (is_array($GLOBALS['SOBE']->editconf['tt_content']) && reset($GLOBALS['SOBE']->editconf['tt_content']) === 'new') {
The error is:
Cannot access protected property TYPO3\CMS\Backend\Controller\EditDocumentController::$editconf
The Var $GLOBALS['SOBE'] is still there, and there is also editconf, but it's not working.
How can I replace this code or rewrite it?
The SOBE object is part by part removed since years. As there are multiple ways for using it - see https://docs.typo3.org/c/typo3/cms-core/main/en-us/search.html?q=sobe&check_keywords=yes&area=default - you may need to take a closer look what is the exact part of replacing this code.
I would guess you can see more at https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.2/Deprecation-84195-ProtectedMethodsAndPropertiesInEditDocumentController.html?highlight=editconf.

Filter collapse issue on small screens

I am using Backpack for Laravel v4.1.10.
After the upgrade from v.4.0 the filter collapse button in small screens stopped working.
On button click my console error is:
TypeError: can't convert n to string
on the following line of bundle.js (line 9920 expanded):
if (!i && o.toggle && /show|hide/.test(n) && (o.toggle = !1), i || (i = new t(this, o), r.data('bs.collapse', i)), 'string' == typeof n)
Other info: php v7.3.9, Laravel v.7.16.1
Apparently it is not a framework bug as it is not existent in the live demo of backpack.
Any feedback to troubleshoot the issue is very welcome.
I fixed the issue by replacing the bundle.js file with the one provided in the official repository of backpack. Maybe it had not been updated at the version upgrade although I cannot fathom a reason for that.

getStructureId returns the real ID minus 1?

this is the code I am using :
JournalArticle article = null;
article = JournalArticleLocalServiceUtil.getLatestArticle(classPk);
String structureId = article.getStructureId();
When I debugged I found that structureId is always the real structureId but minus 1 !!!
Why ?? I need to know if it's Liferay bug ...
thank you,
I am Liferay 6.2 ce ga2.
JournalArticle's field structureId is equivalent not to DDMStructure.structureId, but to DDMStructure.structureKey. I admit, that can be really confusing.
This is due to the DDMStructure's object generation mechanism. When you add new structure using Control Panel, the structureKey is generated automatically using counterLocalService (check this code). As it happens just before the structureId is generated, it is always smaller by one.
See following Jira tickets, where it is explained the structureId vs structureKey issue:
- https://issues.liferay.com/browse/LPS-50671
- https://issues.liferay.com/browse/LPS-31163

jquery version conflit with intuit.ipp.anywhere.js

We are using jquery 1.10.1. we always load 1.10.1 before running intuit.ipp.anywhere.js. The issue we face is that both Jquery 1.6 and 1.10.1(ours) are loaded. despite the fact that there is a checking in intuit.ipp.anywhere.js. after investigating we noticed that the condition window.jQuery.fn.jquery < "1.4.2" is not properly executed. e.g: with JQuery 1.7 we didn't face any issue. It seems that the statement is executed as string compare. Below is the concerned code in intuit.ipp.anywhere.js
if(window.jQuery === undefined || window.jQuery.fn.jquery < "1.4.2") {
// minimum version 1.4.2
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js");
script_tag.onload = function () {
if(window.jQuery) {
intuit.ipp.jQuery = window.jQuery.noConflict(true);
intuit.ipp.anywhere.windowLoad();
}
};
This bug for IE has already been resolved in our previous release.
Please take the latest jquery lib - https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js (if you are loading it locally)
You can also refer-Intuit IPP nuking jQuery in IE

$(this + ":submit") does not work anymore in Jquery 1.8.1

In the past following worked perfectly:
$(this + ":submit").live('click', function (e) {
});
but I just started using JQuery 1.8.1 and I get following error on the selector $(this + ":submit"):
Error: Syntax error, unrecognized expression: [object Object]:submit
'this' is a jquery select on the id of the form $('form1') and results in [ form#form1 ]
What could be an alternative syntax that works with Jquery 1.8.1 and previous versions of Jquery ?
You have to supply this as context
$(":submit", this)
which is equivalent to
$(this).find(":submit")
I would suggest the latter since it makes things more readable.
UPDATE: Just to clarify, I'm editing in #Esailija's comment -
This has never worked! - i.e. $(this + ":submit")
Either this is a submit button and you just need to call $(this), or your submit button is somewhere in the this DOM tree and you should use $(this).find(":submit")