Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

nuSelectBrowse search behavior

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

nuSelectBrowse search behavior

Unread post 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?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: nuSelectBrowse search behavior

Unread post by kev1n »

Hi,

Are you using the latest from Github? Esp. nucommon.js.
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: nuSelectBrowse search behavior

Unread post by chpwebmaster »

2023.30.02
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: nuSelectBrowse search behavior

Unread post by kev1n »

Can you paste the details of the "uncaught type error"?
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: nuSelectBrowse search behavior

Unread post by chpwebmaster »

Message: Uncaught TypeError: Cannot read properties of null (reading '1') - URL: https://nuchp/index.php - Line: 18 - Column: 77 - Error object: {}
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: nuSelectBrowse search behavior

Unread post 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.
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: nuSelectBrowse search behavior

Unread post 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
You do not have the required permissions to view the files attached to this post.
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: nuSelectBrowse search behavior

Unread post 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
chpwebmaster
Posts: 72
Joined: Mon Jun 10, 2019 5:00 pm
Has thanked: 6 times
Been thanked: 4 times

Re: nuSelectBrowse search behavior

Unread post 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
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: nuSelectBrowse search behavior

Unread post 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');
}
Post Reply