Page 1 of 1

nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 4:55 pm
by chpwebmaster
I have a browse form that needs to link to 2 different forms based on which column is checked so I rerouted it through a procedure to determine which since I should have the id (it will be the same primary key for both forms)

Code: Select all

function nuSelectBrowse(e, t) {
    let r = $(e.target).attr('data-nu-primary-key');
    let PullOID = /data-nu-primary-key="([0-9]+)/;
    if(Number.isInteger(Number(r))){
        nuRunPHPHiddenWithParams('BrowseOrderTypeLookup', 'OrderID', r);
    }else if(typeof t !== 'undefined' && 'outerHTML' in t){
        let PKMatch = t.outerHTML.match(PullOID);
        nuRunPHPHiddenWithParams('BrowseOrderTypeLookup', 'OrderID', PKMatch[1]);
    }
}
In the procedure it determines an order type (Estimate, in progress, completed) and it runs

Code: Select all

nuForm('$FormID', '$OrderID', '', '', 0); var nuSelectBrowse = function(e, t){};
The nuSelectBrowse was an attempt to mirror what is in nuform.js to stop it running twice

My problem is that clicking on the red search text throws an uncaught type error (if you click on the second word searched ex: "Web order 98" errors if you click on order) and then adds extra breadcrumbs if you click any of the red text.

Any ideas how to stop the extra breadcrumbs?

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 5:11 pm
by kev1n
Hi,

Are you using the latest from Github? Esp. nucommon.js.

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 5:54 pm
by chpwebmaster
2023.30.02

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 6:47 pm
by kev1n
Can you paste the details of the "uncaught type error"?

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 6:50 pm
by chpwebmaster
Message: Uncaught TypeError: Cannot read properties of null (reading '1') - URL: https://nuchp/index.php - Line: 18 - Column: 77 - Error object: {}

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 6:54 pm
by kev1n
Does the error come from nuSelectBrowse() or some other code you're calling from the procedure?
If you're not sure, you can comment nuRunPHPHiddenWithParams() out.

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 6:57 pm
by chpwebmaster
it's coming out of the PKMatch[1] if i just put that in a console.log with it commented out I still get the error but it only seems to happen on the second word

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 7:09 pm
by chpwebmaster
I just tried something stupid I logged in as a user and it seems to work I don't even get the double arrows anymore (I was as a user in an earlier test). it just seems to fail under admin

Re: nuSelectBrowse search behavior

Posted: Thu Mar 30, 2023 7:16 pm
by chpwebmaster
Ok now I'm really questioning my sanity I just logged back in as admin and it's working fine. I'm absolutely positive I've logged out and in again as well as clearing the browsers cache and cookies since I ran the update

Re: nuSelectBrowse search behavior

Posted: Sat Apr 01, 2023 11:52 am
by kev1n
This is the suggested method for obtaining the primary key. If keyboard navigation is used, the event may be an empty string, which could potentially lead to an error.
Therefore it's recommended to use the element to retieve the primary key.

Code: Select all

function nuSelectBrowse(event, element) {
    const primaryKey = $(element).attr('data-nu-primary-key');
}