2014-11-16 2 views
0

У вас есть быстрый вопрос о x-Editable select.jQuery X-editable pass selected text from select

Я хотел бы выделить текст выбранного элемента в элементе select и передать его обработчику .Net, чтобы его можно было добавить в таблицу аудита позже.

Есть ли у кого-нибудь идеи, как я могу это сделать?

Это то, что я в настоящее время:

Anchor Код:

<a class='editable' data-type='select' data-name='statusid' data-pk='1027' data-params='{"original": "In Progress"}' data-value='2' data-source='handlers/getHDMLists.ashx?l=1' id='status'>In Progress</a> 

и JQuery сообщение:

$('#status').editable({ 
       showbuttons: true, 
       url: function (params) { 
        return $.ajax({ 
         type: 'POST', 
         url: 'handlers/putHDMTicketDetails.ashx?ac=1', 
         data: params, 
         params: '{"new": "' + $(this).text() + '"}' , 
         async: true, 
         cache: false, 
         timeout: 10000, 
         success: function (response) { 
          if (response != null) { 
           if (response.msg == "SUCCESS") { 

            $.gritter.add({ 
             title: 'Update Successful', 
             text: 'Support ticket details update was successful.', 
             class_name: 'gritter-success gritter-center gritter-light' 
            }); 

           } else { 

            $.gritter.add({ 
             title: 'Something went wrong!', 
             text: 'There seems to have been an error with your requested update, please try again and if you continue to receive this message please contect your site administrator.', 
             class_name: 'gritter-error gritter-center' 
            }); 

           } 
          } else { 

           $.gritter.add({ 
            title: 'Something went wrong!', 
            text: 'There seems to have been an error with your requested update, please try again and if you continue to receive this message please contect your site administrator.', 
            class_name: 'gritter-error gritter-center' 
           }); 
          } 

         }, 
         error: function() { 
          $.gritter.add({ 
           title: 'Something went wrong!', 
           text: 'There seems to have been an error with your requested update, please try again and if you continue to receive this message please contect your site administrator.', 
           class_name: 'gritter-error gritter-center' 
          }); 
         } 
        }); 
       } 
      }); 

Как вы можете видеть, что я могу получить исходный текст, используя place-params placeholder в anochor, но я попытался захватить новый выделенный текст, используя $ (this) .text(), но он игнорируется :-(

Любая помощь будет замечательной.

Оз

ответ

0

ИТАК после немного отслеживания выясняется, что входные элементы, представленные X-редактируемого не имеют идентификаторы или имена доступны, однако, они обернуты в DIV с классом редактируемых -input.

Изменение выше строки кода из:

url: 'handlers/putHDMTicketDetails.ashx?ac=1', 

в

url: 'handlers/putHDMTicketDetails.ashx?ac=1&new=' + $('.editable-input').find(':selected').text(), 

сортирует проблема красиво и последовательно работает на всех входных элементов.

Oz