Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter Data in Other Fields - Previously Selected Cron Disappears #7

Closed
damogallagher opened this issue Mar 10, 2015 · 1 comment
Closed

Comments

@damogallagher
Copy link

Hi

I have adapted your Bootstrap3 demo to show you a bug I have encounterd. All I have done is add a new textfield to the mix. The code is below

The issue is, if i select a cron value, then edit another text field. The cron value dissappears and it is empty when I submit the form

I need to have other form elements on my page. Have you any suggestions on what I can do?

Cheers
Damien

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.css" rel="stylesheet">
    <link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <title></title>
</head>
    <body>
    <div class="container">
        <form role="form" class="form-inline">
            <div class="form-group">
                <label for="scheduleName">Schedule Name</label>
                <input id="scheduleName" class="form-control" type="text"/>
            </div>
            <div class="form-group">
                <label for="cron">Cron</label>
                <input id="cron" class="form-control" />
            </div>
        </form>
    </div>       

    <script>
            $(function () {
                $("#cron").cronGen();                
            });
        </script>
        <script src="CronGen.js"></script>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.js"></script>
    </body>
</html>
@damogallagher
Copy link
Author

Hi

i think I have found the problem and the solution

The problem code is as follows

                $("#CronGenMainDiv select,input").change(function (e) {
                    generate();
                });

The input selector is not only selecting inputs within the cronGen plugin, it is also selecting every other input field on the page

The following small change fixes the issue

                $("#CronGenMainDiv select,#CronGenMainDiv input").change(function (e) {
                    generate();
                });

Cheers
Damien

@hsal hsal closed this as completed May 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants