0

i create the html items dynamically with Django.

{% for scraper in scrapers %}
<div class='scraper_item'>
        <ul class="scraper_actions1">
        <li><a href="/schedule/{{ scraper.id }}">Schedule</a></li>
        <li><a class="delete" id="{{ scraper.id }}" href="/delete/{{scraper.id}}">Delete</a></li>
    </ul>
</div>
{% endfor %}

I pass 'scrapers' as the model objects into html page and list them. I want to process each object selected by id with the same jQuery function. How can i do selection of a particular element to pass it to Django views def delete(request, scraper_id) without multiply coding?

$("a.delete").click(function(event){
        alert("going to delete...");
                    ...???
            return false;    
        });    
1
  • Do you ask how to find the ids of the elements or you wonder how to send a jQuery request? Commented Aug 21, 2012 at 15:58

1 Answer 1

1

Try the next code to find an 'id' attribute of an element:

$( event.target ).attr( 'id' )

More info.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.