Provide supplementary data when calling the destory() function in Backbone

I've been attempting to include extra information in my backbone destroy method. I've tested the following approaches, but none of them seem to be effective:

model.destroy({'contentType': 'application/json', 'data': {'wow': 1} })
model.destroy({'headers': {'wow': 1}})
model.destroy({'data': {'wow': 1}})

Can someone help me understand what I might be doing incorrectly? I can't seem to get it to work.

EDIT: Following advice from @MorKadosh, I included processData in the request.

model.destroy({data: {wow: 1}, processData: true})

In the network request, I can observe that 'wow' is being transmitted as form data.

Now, on the backend, I'm using Tastypie. How do I retrieve 'wow' in obj_delete of Tastypie?

Tasypie's obj_delete accepts bundle and **kwargs. I have printed out the following, but none of them contain 'wow'.

print bundle.data
for name, value in kwargs.items:
  print name, value
print bundle.request

Am I overlooking something?

Answer №1

remove involves making use of an AJAX REMOVE method ($.ajax). In order to properly handle the data, you must also include processData:true to give jQuery permission to process the extra data.

Here is an example of how you would implement this:

    this.model.remove({
        data: { hello:1 },
       processData:true
    });

You can view the demonstration here: http://jsfiddle.net/x78waqyz/5/ (open the network tab and observe the request)

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

What steps can be taken to fix the error message 'Uncaught TypeError: (...) is not a function'?

I have already checked a similar question on stackoverflow, but it does not address the specific issue I am facing with the error. My goal is to ensure that both scripts, embed.js (plugin) and more-content-arrow.js (custom script), work correctly on the p ...

Tips for choosing a single checkbox from a set of multiple checkboxes in React.js

I iterated through a list of objects to generate table rows, each containing an input tag with the type set as checkbox. const [ isChecked, setIsChecked ] = useState(false); const handleChange = (e) => { setIsChecked(e.target.checked) ...

What methods can be used to modify the behavior of tiptap when pasting plain text?

Currently, my goal is to create a visual editor by utilizing the tiptap library. Although v2 of tiptap is more commonly used, there are instances where v1 is necessary. However, I encountered an issue with tiptap's behavior when pasting plain text, ...

Excessive white space at the bottom of a floated image within a small parent element

I need help with styling a page that will only be viewed on mobile Safari. The HTML markup is as follows: <blockquote> <p><img src="..."/> A paragraph...</p> <p>...</p> ... </blockquote> Here is the CSS u ...

Ways to test the initial launch of an Android application using Cordova

I am developing an Android application using Cordova. My app consists of multiple pages, with the main homepage being index.html. I need to determine if it is the first time a user lands on the homepage after opening the app, regardless of how many times ...

Utilize the jQuery live() function on a single element

Looking for a solution to an issue with my Facebook-Like Chat on . Currently, the chat opens multiple bars when clicked, but only closes all at once. How can I make it so that each chat bar opens and closes individually when clicked? Any help would be ap ...

Utilizing JavaScript Callbacks in HTML Image Tags

Currently I am working on a small application and looking to include a YouTube section. I have come across a method for obtaining the user's YouTube icon: This is included in the head section of my code: <script type="text/javascript" src="http:/ ...

During the execution of my asynchronous javascript, it interrupts the flow of the other function

How can I ensure that a function executes after another one in Vue.js? I've tried various methods like async/await, callback functions, and .then, but none seem to work seamlessly. Any suggestions for a possible solution? auth_util.js: async auth () ...

What steps can be taken to resolve the dependency problem with npm installation?

Attempting to incorporate npm install react-material-ui-carousel --save into my react project has presented a challenge. Upon installation, I encountered a dependency tree issue. Even after deleting the lock and npm modules files, followed by running npm ...

Step-by-step guide on how to index timestamp type using Knex.js

I'm in the process of indexing the created_at and updated_at columns using knex js. However, when I try to use the index() function, I encounter the following error: Property 'index' does not exist on type 'void' await knex.sche ...

Can someone guide me on how to iterate through a form in jQuery starting from the bottom and moving upwards, beginning with the innermost element, when the ID of the deepest element is unknown

Within my MVC web application, I have implemented a dynamic form builder that organizes forms into sections and questions. Sections can contain either questions or more sections. The objective is to have certain sections open based on specific question in ...

Using jQuery to select and animate several elements simultaneously without repeating the animation

Issue Summary (Fiddle): I'm trying to make all elements fade out simultaneously when clicked, but the current code causes the target to trigger three times resulting in three alert() calls. I want them to fade together without using a wrapper element ...

What is preventing Angular from loading on this Plnkr?

I've spent time researching my problem and testing various solutions, but I still can't seem to resolve it. Angular doesn't appear to be loading correctly in Plunker for some reason. I've heard that ng-app is no longer supported in ne ...

Vue 2 - Error: The function is not defined at HTMLInputElement.invoker (vue.esm.js?65d7:1810)TypeError: cloned[i].apply

I encountered the following error: Uncaught TypeError: cloned[i].apply is not a function at HTMLInputElement.invoker (vue.esm.js?65d7:1810) I have set up my project using vue-cli (simple webpack), and below is the code for my component: <template ...

What is the best way to assign specific codes to separate pages using a single JS file?

I am currently working on a project that involves an authentication JavaScript which is responsible for managing user sign-ins and registrations. However, there are certain lines of code within this script that impact different pages in various ways. I n ...

What is the best way to emphasize an element on a webpage with Selenium and Python?

Recently, I inherited an existing selenium framework that utilizes Python for scripting. In order to aid in debugging and other tasks, I am interested in implementing a feature that highlights the element currently being acted upon (such as an input box, l ...

Display the DIV element once a specific number of radio buttons have been selected

I need help figuring out how to display a DIV after a specific number of radio buttons are selected. Currently, I have it set up to appear only when all the radio buttons are selected thanks to some guidance from others who had similar questions. However, ...

Exporting Canvas data without the alpha channel

I am looking for a way to resize images that are uploaded in the browser. Currently, I am utilizing canvas to draw the image and then resize it using the result from the toDataURL method. A simplified version of the code (without the upload section) looks ...

Configure Protractor's configuration file to utilize a personalized reporter

I'm in the process of setting up end-to-end tests using protractor.js, but I am not happy with how the default reporter displays results on my terminal window. Is there a way to customize the reporter configuration to make it easier to read and more ...

Conceal a div once the content in a separate div has finished loading

After loading an image in slices inside a div, I want to ensure that the entire content is loaded before displaying the div. To achieve this, I am using another div as a mask while the content loads: <div id="prepage" style="position:absolute; left:0px ...