locked
passing two paramters with remote from a webgrid - unsupported pseudo RRS feed

  • Question

  • User379720387 posted

    I am using a web grid.

    The grid rows are made clickable, and when clicked a modal opens and it passes the value of the first column in that row.

    The first value is the id for the record I want to display inside the modal.

    <script> $(document).ready(function () {
        $('tbody tr, .alternate').on('click'function () {
            $('#detailsModal').removeData('bs.modal');
            $('#detailsModal').modal({             
    keyboard: false,              
    remote: {                 
    url:'DetailsClients/' + $(this).find("td:first").text()     
    });     
    });    
    });
    </script>

    This works nicely, now with some new functionality I need to pass to values:

    url:'DetailsClients/' + $(this).find("td:first").text() + '/' + + $(this).find("td:second").text()

    For testing purposes I have put the second value in the second column.

    Now I get "unrecognized pseudo on :second"

    What is the proper way of doing this, and how can I pass the second value from any column I choose?

    TIA

    Robert

    Monday, September 21, 2015 8:34 AM

Answers

  • User281315223 posted

    Instead of "second", which isn't a supported pseudoselector, try using nth-child :

    url:'DetailsClients/' + $(this).find("td:first").text() + '/' + $(this).find("td:nth-child(2)").text()

    Where n would be the column that you would want to pass through.

    What is the proper way of doing this, and how can I pass the second value from any column I choose?

    It really depends on how your routes are defined, your current approach appears to use a series of slashes '/' to separate your different values, however you would always use querystring parameters to indicate what each of the values are :

    url:'DetailsClients/?parameterA=' + $(this).find("td:first").text() + '&parameterB=' + $(this).find("td:nth-child(2)").text()
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2015 8:41 AM
  • User281315223 posted

    I have always assumed the parameter names are not necessary in my case because I am not interested in any search engine tie in.

    They aren't really necessary for search engine, but they can help with clarification as to what the actual parameters are. But if you are already using routing via the UrlData or RouteValues collections, you should be fine.

    N = number of column

    td:nth-child(N)

    This syntax should be correct. If you were looking for the second <td> element within a row, you would use :

    // Assumes that this is the <tr> element (row)
    var secondRowText = $('td:nth-child(2)',this).text();

    You could also look at the :eq(n) pseudoselector, which works similarly. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2015 9:23 AM

All replies

  • User281315223 posted

    Instead of "second", which isn't a supported pseudoselector, try using nth-child :

    url:'DetailsClients/' + $(this).find("td:first").text() + '/' + $(this).find("td:nth-child(2)").text()

    Where n would be the column that you would want to pass through.

    What is the proper way of doing this, and how can I pass the second value from any column I choose?

    It really depends on how your routes are defined, your current approach appears to use a series of slashes '/' to separate your different values, however you would always use querystring parameters to indicate what each of the values are :

    url:'DetailsClients/?parameterA=' + $(this).find("td:first").text() + '&parameterB=' + $(this).find("td:nth-child(2)").text()
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2015 8:41 AM
  • User379720387 posted

    UrlData[0]  and UrlData[1] give me the values on the DetailsClients page. I know what they are.

    I have always assumed the parameter names are not necessary in my case because I am not interested in any search engine tie in.

    Or am I missing something?

    N = number of column

    td:nth-child(N)
    Monday, September 21, 2015 9:14 AM
  • User281315223 posted

    I have always assumed the parameter names are not necessary in my case because I am not interested in any search engine tie in.

    They aren't really necessary for search engine, but they can help with clarification as to what the actual parameters are. But if you are already using routing via the UrlData or RouteValues collections, you should be fine.

    N = number of column

    td:nth-child(N)

    This syntax should be correct. If you were looking for the second <td> element within a row, you would use :

    // Assumes that this is the <tr> element (row)
    var secondRowText = $('td:nth-child(2)',this).text();

    You could also look at the :eq(n) pseudoselector, which works similarly. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 21, 2015 9:23 AM