question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Events not firing

See original GitHub issue

I have registered the events click, selected e deselected but the events selected e deselected does not fires. The grid is inside a modal.

below is the code of my initialization.

$(document).ready(function () {
        $("#grid-consultaendereco").bootgrid({
            ajax: true,
            url: "/Public/ConsultarEndereco",
            selection: true,
            multiSelect: false,
            rowSelect: true,
            searchSettings: {
                delay: 100,
                characters: 3
            },
            labels: {
                all: "Todos os registros",
                loading: "Aguarde carregando...",
                refresh: "Atualizar",
                search: "Procurar",
                noResults: "Sem registros",
                infos: "Exibindo {{ctx.start}} até {{ctx.end}} de {{ctx.total}} registros"
            }
        }).on("selected.rs.jquery.bootgrid", function (e, rows) {
            console.log(row);
            alert("selected");
        }).on("deselected.rs.jquery.bootgrid", function (e, rows) {
            alert("deselected");
        }).on("click.rs.jquery.bootgrid", function (e,columns,rows) {
            alert("click");
        });

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
LeandroBarralcommented, Dec 1, 2015

Try to add data-type=“numeric” on your data-identifier.

method: Grid.prototype.select

looking the code, on the line ~1570: if (this.currentRows[i][this.identifier] === id)

note to ===, that returns false if row data is '1' (string) and id is 1 (numeric) if your prefer you can modify this line replacing === to == then the condition will return true.

looking below you can see inside other ‘if’ the code: (line ~1605) this.element.trigger("selected" + namespace, [selectedRows]); //self explainable

1reaction
RHOPKINS13commented, Jan 1, 2016

I ran into this problem too, but for some reason adding data-type=“numeric” and data-converter=“numeric” did not work. I found that the IDs in my data were strings (I’m using MySQL, PDO and json_encode in PHP on my backend). I ended up having to loop through my dataset before calling json_encode, casting the IDs to integers. Now my events fire fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event listeners not working? 3 key areas to troubleshoot
Are your event listeners not working as you'd expect? Here are 3 key areas to troubleshoot to help you get everything triggering as...
Read more >
jQuery event not firing - javascript - Stack Overflow
If you happen to use .remove() to extract something temporarily from the DOM and then reinsert it, then you will lose your events....
Read more >
Events not firing (or being handled) - Laracasts
I noticed you said "handler" when referring to what normally is called a "listener." A listener must be registered to an event before...
Read more >
Events not firing - Scripting Support - DevForum | Roblox
Now I'm not 100% that CharacterAdded doesn't fire in local scripts but I don't think thats the problem since CharacterAppearanceLoaded fires.
Read more >
Bind Events To Not firing - Unreal Engine Forums
You have bound to the event, but you haven't fired the event. You need to call 'test event'. I think you're going to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found