Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mitra 81 posts 196 karma points
    Mar 10, 2015 @ 11:03
    Mitra
    0

    Apply filters to MNTP with ajax

    Hello,

     

    I have got a career page, each career has got 5,6 multiple node tree picker.

    I have got lots of filters in the page, I page the value for filters with ajax to the hidden fileds in the page, but after that i am not sure how to retrive the data as there are lots of MNTP that each of them has got foreach.

     

    all of the code is in a macri script, cshtml page.

     

    anyone can help me?

    example of my code:

     

     @foreach (var itemGroup in pagesToList.InGroupsOf(3))

                             {

                                 foreach (var careerItem in itemGroup.OrderBy("createDate descending"))

                                 {

    <div id="careers-items" class="grid-12">

                                             <div class="grid-8">

                                                    <h4>@careerItem.jobTitle</h4>

                                                    <p>@careerItem.frontPageText</p>

     

                                                                            <div class="grid-2 smaller-font"><img src="/media/1054/pound.png" alt="" /> @careerItem.salary</div>

                                                                            <div class="grid-2 smaller-font"><img src="/media/1052/location.png" alt="" /> 

                                                                            @if (careerItem.HasValue("_locationPicker"))

                                                                            {

                                                                                string[] loc_ids = careerItem._locationPicker.Split(',');

                                                                                foreach (string locid in loc_ids)

                                                                                {

                                                                                    var node = Library.NodeById(locid);

                                                                                    if (node.Id != 0)

                                                                                    {

                                                                                        // If node exists:

                                                                    @node.name

                                                                                    }

                                                                                }

                                                                            }

                                                                            </div>

                                                                            <div class="grid-2 smaller-font"><img src="/media/1055/type.png" alt="" /> 

                                                                            @if (careerItem.HasValue("_jobTypePicker"))

                                                                            {

                                                                                // use split on comma as mntp set to csv in cms

                                                                                string[] type_ids = careerItem._jobTypePicker.Split(',');

                                                                                foreach (string typeid in type_ids)

                                                                                {

                                                                                    var node = Library.NodeById(typeid);

                                                                                    if (node.Id != 0)

                                                                                    {

                                                                                        // If node exists:

                                                                    @node.name

                                                                                    }

                                                                                }

                                                                            }

                                                                            </div>

                                                                            <div class="grid-3 smaller-font"><img src="/media/1053/posted.png" alt="" /> Posted: @careerItem.createDate.Date.ToString("M")</div>

                                                                            <div class="grid-3 omega smaller-font"><img src="/media/1055/type.png" alt="" />

                                                                            @if (careerItem.HasValue("_jobLevelPicker"))

                                                                            {

                                                                                // use split on comma as mntp set to csv in cms

                                                                                string[] level_ids = careerItem._jobLevelPicker.Split(',');

                                                                                foreach (string levelid in level_ids)

                                                                                {

                                                                                    var node = Library.NodeById(levelid);

                                                                                    if (node.Id != 0)

                                                                                    {

                                                                                        // If node exists:

                                                                    @node.name

                                                                                    }

                                                                                }

                                                                            }

                                                                            </div>

                            

                                                </div> 

                                                                <div class="grid-4 omega" >

                                                                        <p><a class="red-link apply" href="@careerItem.url">Apply</a></p>

                                                                </div>

                                                          </div>

                                     }

                                 }

     

    jQuery.ajax({

                        type: 'POST',

                        url: ajaxurl,

                        dataType: 'json',

                        data: {

                            action: 'filter-jobs',

                            type: type,

                            country: country,

                            location: location,

                            salary: salary,

                            level: level,

                            keyword: keyword

                        },

                        success: function (response) {

                            console.log(response);

     

                            //jQuery.each(response.member, function (key, value) {

                            //    var htmlOutput = template.render(value);

                            //   staffList.append(htmlOutput);

                            //});

                        }

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies