0

Is there a way to refresh a query driven CFSELECT with JQuery?

Here is my scenario:

I have a CFSELECT that is populated using cfquery

<cfselect name="descriptionDD1" id="descriptionDD1" query="customDescriptions" value="description" queryPosition="above">
   <option value="add_new">ADD NEW</option>
</cfselect> 

If a user clicks the "ADD NEW" option, a MODAL is popped where they can add to this very list of data in the database that the CFSELECT is pulling from. Here is the AJAX post:

  <script>
   $(function(){
   //Add a new note to a link
   $("#addDescriptionForm").submit(function(){
      // prevent native form submission here
        $.ajax({
            type: "POST",
            data: $('#addDescriptionForm').serialize(),
            url: "actionpages/add_descriptions_modal.cfm",
            success: function() {
              $("#addDescriptionResponse").append( "Successfully added description." );
              }    
        });
        return false;           
        });
      });
      </script>

I have that part working, however after a user adds the new data and closes out the MODAL window, you have to refresh the whole page to see the updated CFSELECT list.

This is not desirable because if you refresh the whole page, then the user will loose the information that they have inputted into other form elements.

So is there a way I can tell just the CFSELECT element to update itself to retrieve the updated list of data?

Thank a bunch. -Brian

Brian Fleishman
  • 1,237
  • 3
  • 21
  • 43
  • Duplicate? http://stackoverflow.com/a/5893744/1636917 – Miguel-F Aug 27 '14 at 19:15
  • No, I did see that post but they are using the CFBIND command and are refreshing that way. Don't think that applies to my scenario. – Brian Fleishman Aug 27 '14 at 19:22
  • 3
    The only way to refresh the select is with a new request to the server, either by submitting the whole page -or- via an ajax request. It does not seem like `cfselect` buys you anything here. Why not just use a plain ` – Leigh Aug 27 '14 at 19:59
  • Yeah that seems like a more logical approach. I'll try to put something together and report back my results. – Brian Fleishman Aug 27 '14 at 21:28
  • @Leigh - Well, I've hit a wall with trying to come up with an AJAX way to do this. Here is my [link]( http://stackoverflow.com/questions/25571224/populate-selectlist-with-ajax?noredirect=1#comment39936615_25571224) – Brian Fleishman Aug 29 '14 at 16:23
  • As you already received an answer to this question on another thread, voting to close this one as a duplicate. – Leigh Sep 06 '14 at 21:34

0 Answers0