Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6877137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:33:49+00:00 2026-05-27T04:33:49+00:00

According to jro suggestion I am modifying my question and problem I have. ==

  • 0

According to jro suggestion I am modifying my question and problem I have.

==URL==

url('^$','pMass.views.index', name='index')  #Index is the main view with form input type text and submit
                                             #If search value is match then it will render result.html template

==VIEW==

#View will find search value and render result.html template if request is not ajax
#If request is ajax then same view will create new queryset and render to same template page (result.html) 

 def index(request):
    error = False
    cid = request.GET

    if 'cnum' in request.GET:
       cid = request.GET['cnum']

    if not cid:
       error = False
       expcount = Experiment.objects.count()
       allmass = SelectedIon.objects.count()

   if request.is_ajax():
       value = request.GET.get('value')
       if value is None:
           result = SelectedIon.objects.filter(monoiso__iexact=value).select_related()
           template = 'result.html'
           data = {
               'results':result,
           }
           return render_to_response(template, data,           
          context_instance=RequestContext(request))

    else:

       defmass = 0.000001
       massvalue = float(cid)
       masscon = defmass * massvalue
       highrange = massvalue + masscon
       lowrange = massvalue - masscon

       myquery = SelectedIon.objects.select_related().filter(monoiso__range=(lowrange, highrange))
       querycount = myquery.count()

       return render_to_response('result.html', {'query': cid, 'high':highrange, 'low':lowrange, 'sections':myquery, 'qcount':querycount, })

   return render_to_response('index.html', {'error': error, 'exp': expcount,'mass':allmass,})

==result.html==

# I have divided template into two container: main (left) & container (right)
# Left container is for search match (e.g value/title) with hyperlink
# Right container is for detail of the match value
# For right container I have created jQuery tabs (tab1, tab2, tab3)
# The content of the right container in the tab will update according to the link in the left.
#Layout is given below

               ! tab1  ! tab2 ! tab3 !            
-------------------------------------------------------------------------               
!  434.4456    !  Show Default Match 1 Record                           !
!  434.4245    !  &  left hyperlink onclick show it's value record      !
!  434.4270    !  detail. I have design tab with JQuery                 !
!  434.2470    !                                                        !
!  434.4234    !                                                        !
------------------------------------------------------------------------- 

==Left container(result.html)==

#I am looping through the queryset/list of values that was match with template for tag
#The template variable is given a hyperlink so after clicking it's detail information 
 will be shown on right container

<script type="text/javascript" src="/media/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#a.id').click(function(){
        value = $ ('a.id').val();
        $('div#tab_content')empty().load('{%url index%}?query'= +value);
        });
    });

<div id="main">
     <table align="center" cellspacing="0" cellpadding="4" border="1" bordercolor="#996600">
          <tr>
              <th>Match</th>
          </tr>     
               {% for section in sections %}
          <tr>
              <td><a href="#" id="{{%section.monoiso%}}">{{section.monoiso}}</a></td>
          </tr>
               {% endfor %}
       </table>
</div>

==PROBLEMS==

  • I don’t know how to get hyperlink value!
  • jQuery ajax request on hyperlink (left container) is not working
  • I am not sure about loading index view from result.html is correct
  • I am sending data to server from the hyperlink with <a href.... id="{{%section.monoiso%}}", how can I use same id value for querying in the index view and response in the result.html?
  • How to render response in the right container?

Suggestions, comments and answer are appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:33:50+00:00Added an answer on May 27, 2026 at 4:33 am

    Some starting points. First, the view you call via Ajax does not necessarily have to return a json-object: the data can also be returned as a string using django.http.HttpResponse (or render_to_response, which boils down to the same thing). This means you can also return an entirely generated template as usual.

    Assuming your posted view is found at /index/(?<tab>\d+)/(?<match>\d+)/ (tab being the tab index, match being the match index), your javascript could look like this:

    $("ul.tabs li").click(function() {
        $("ul.tabs li").removeClass("active");     // Remove any "active" class
        $(this).addClass("active");                // Add "active" class to this tab
        $(".tab_content").hide();                  // Hide all tab content
    
        // Construct the url based on the current index
        match_name = $("ul.match li").index($("ul.match li.active"));
        url = "/index/" + $("ul.tabs li").index($(this)) + "/" + match_name + "/";
    
        // Asynchronous ajax call to 'url'
        new $.ajax({
            url: url,
            async: true,
            // The function below will be reached when the request has completed
            success: function(transport)
            {
                $(".tab_content").html(transport); // Put data in the div
                $(".tab_content").fadeIn();        // Fade in the active content
            }
        });
    });
    

    I didn’t test this, but something along these lines should do. Note that for this to work with your current code, you view’s index function needs to allow for a parameter. If you just want to test it with the same page for each tab, make the url look like this: url = "/index/"; so that it’ll most likely work right away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to W3C standards, if you have a nillable element with a nil value,
According to MSDN , a hash function must have the following properties: If two
According to php manual nor php://input neither $HTTP_RAW_POST_DATA work with multipart/form-data POST-requests. php://input allows
According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL() ? RightToLeft.True : RightToLeft.False; is
According to select name from system_privilege_map System has been granted: SELECT ANY TABLE ...and
According to what I have found so far, I can use the following code:
According to the answers to this question, I cannot embed a file version in
According to MS when you show a modal form in VB6 it does not
According to the site, http://www.dba-oracle.com/t_nls_lang.htm Problem might occur even if both the database and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.