Search code examples
jqueryasp.net-mvcjeditable

Is there anyway to in jeditable to removing submit button when using select


Can you have a jeditable select that submits on selecting the dropdown (instead of needing the extra 'submit' ok button.


Solution

  • I think I have found a solution to this problem.

    Knowing that jeditable will generate following html

    <div id="status" class="editable_select">
        <form>
            <select name="value">
                <option value="Active">Active</option>
                <option value="Inactive">Inactive</option>
            </select>
            <button type="submit">Save</button>
            <button type="cancel">Cancel</button>
        </form>
    </div>
    

    I have just added following jQuery code

    <script type="text/javascript">    
        $(document).ready(function () {        
    
            $('select').live('change', function () {
                 $(this).parent().submit();
            });
        });
    </script>
    

    (see jQuery + Jeditable - detect when select is changed)

    HTH