Verify if the backgrid cell has been modified

I am currently working on a custom cell editor and I'm looking for another way to check if a cell has been edited. Below is the code snippet I am using:

Backgrid.CustomDateCell = Backgrid.DateCell.extend({
    editor: Backgrid.InputCellEditor.extend({
        attributes: {
            type: "text"
          },
        events: {},
        initialize: function(){
            Backgrid.InputCellEditor.prototype.initialize.apply(this, arguments);
            var _input = this;
            $(this.el).prop('readonly', true);
            $(this.el).datepicker({
                autoclose: true,
                todayHighlight: true,
                format: "mm/dd/yyyy",
                viewMode: "months",
                minViewMode: "months"
            });
            $(this.el).on('hide', function(e){
                var command = new Backgrid.Command({});
                _input.model.set(_input.column.get("name"), e.date);
                _input.model.trigger("backgrid:edited", _input.model, _input.column, command);
                command = _input = null;

                $(this).parent('td').addClass('cell-edited');
            });
        }
    })
});

Unfortunately, the part where I try to select the parent td of the current datetimepicker and add a new class is not functioning as expected. While I work on resolving this issue, I wanted to inquire whether backgrid offers a more efficient method for checking if a cell has been edited.

Thank you in advance

Answer №1

After some tinkering, I managed to get my code working by including a listener during the setup of the custom cell.

this.listenTo(_input.model, "backgrid:edited", function(){
                $(this.el).parent().parent().addClass('cell-edited');
            });

I am still interested in finding a solution to my original query.

Many thanks

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Flow bar for micro-tasks

In my current project, I am faced with the task of organizing a series of 4 mini tasks and displaying to the end user which specific mini task they are currently on. To accomplish this, I have been utilizing image tags for each task. <img>1</img ...

Frequent execution of jQuery Ajax requests is evident

Using a live operator, I attach a click function to a li-element: $(".UListView li input.iconbutton.click").live("click", function(e){ e.preventDefault(); [...] $.get("ajax/categorylist.php?appendcategories=true&parentcat="+currentid+"&side="+sid ...

Employing conditional statements in jQuery templates

Can if statements be incorporated into a jQuery tmpl template? <script id="template" type="text/html"> <h1>${someVar}</h1> if (${intro}!="") <small>${intro}</small> endif <p>${restOfVariables}< ...

An issue with jQuery and LESS causing stylesheets to update only once

Struggling with updating a custom CSS href - everything works perfectly the first time, but subsequent updates do not reflect any changes on the page. Even though I can see the href updating in Chrome debugger and there are no errors being thrown by LESS, ...

Guide on sending the API key to an API gateway through a request header with Jquery AJAX

I am facing an issue posting JSON data to an AWS API gateway that is protected by an API key. I managed to make the POST request successfully using Postman by adding the x-api-key header. However, I am struggling to achieve the same with JQuery code. How c ...

Continuously encountering the "Uncaught Error: Bootstrap dropdown requires Popper.js" message despite having already added popper.js to the code

Recently beginning my journey with Angular and Bootstrap, I decided to create a simple "hello world" app. I've included all the necessary libraries, but I encountered an error that has me stuck. Error: Bootstrap dropdown requires Popper.js I' ...

Obtain HTML tags from RSS CDATA section

Is there a way to extract HTML tags from a CDATA tag in an RSS feed? I have utilized a basic jQuery function to retrieve the JSON object from the RSS, below is my code: $.get("someURL", function(data) { console.log('InGet'); ...

Identify the Google Maps Marker currently displayed on the screen

Is there a way to generate a list of markers within the zoom range for Google Maps, similar to the functionality on this site I'm curious if I can achieve this using jQuery or if there is a built-in function for Google Maps v3? Thank you! ...

I need to see the image named tree.png

Could someone assist me in identifying the issue with this code that only displays the same image, tree.png, three times? var bankImages = ["troyano", "backup", "tree"]; jQuery.each( bankImages, function( i, val ) { $('#imagesCon ...

How do I make sure an onchange event triggers when updating element values in jQuery?

In my view, I have an address block that can update some data when a user clicks a checkbox. This functionality is achieved through the following javascript function: <script type="text/javascript"> $().ready(function() { $("#UseAccountA ...

Having numerous bxsliders implemented in a Genesis child theme

I'm currently working on incorporating multiple bxsliders through custom fields in a wp genesis child theme. The initial slider was successfully implemented using the following function within the genesis child theme functions: add_action('genes ...

Tips for customizing the jQuery countdown styling

Currently, I have incorporated the jQuery countdown into my project which consists of solely the essential Javascript required for the countdown to function. However, I am interested in achieving a similar visually appealing "animated" style similar to t ...

Error in licensing for PHP and JQuery in Bluemix platform

Currently, I am in the process of creating a validation form using Bluemix DevOps. My approach involves utilizing jQuery and PHP to cross-check whether an email address already exists in the database. Here is an excerpt of the code snippet: if(error == 0) ...

JavaScript for varying content that is dynamically loaded on a completely ajax-powered website

This post has been updated to address the issue more effectively with a refined concept and code (based on the responses provided so far) I am working on developing an ajax-driven website, but I have encountered some issues with multiple bound events. He ...

When adding a new div, ensure it is counted and delete it once a new div is added

When clicked, a new div is added. When clicked again, another div with the same content is created as a duplicate. Q: Is there a way to remove the previous div when a new one is created? $(document).on('click', '.LibSectOpen', functio ...

What is the process for uploading an image encoded in base64 through .ajax?

I am currently working with JavaScript code that successfully uploads an image to a server using an AJAX call. Here is the ajax call snippet that is functioning properly. $.ajax({ url: 'https://api.projectoxford.ai/vision/v1/analyses?', ...

Discover the power of the "Load More" feature with Ajax Button on

After browsing through the previous questions and experimenting with various techniques, I've come close to a solution but still can't get it to work. The closest example I found is on Stack Overflow: How to implement pagination on a custom WP_Qu ...

The functionality of Bootstrap toggle ceases to operate properly following an AJAX content update

I am currently using AJAX load to fetch some content on my webpage. I am working with Bootstrap 3 and Bootstrap toggle. When the content is loaded, the Bootstrap 3 content functions properly (the panel-primary panel is clearly visible). However, the Bootst ...

Failure to create an array when parsing JSON data from an Ajax request

Utilizing Ajax to call an SP that returns a string. var AjaxData = $.ajax({ type: "POST", contentType: "application/json;", url: "WebForm1.aspx/GetHeartBeatData", data: "{}", dataType ...

Connect to dynamically generated div on separate page

I am facing an issue with my navigation bar drop down menu that displays event titles fetched from the database. I want users to be able to click on a specific event and have the page scroll to the dynamically generated content for that event. However, it ...