Skip to content

Commit 10df0c1

Browse files
committed
Adding the new event page to requirejs
1 parent 29c8d99 commit 10df0c1

File tree

7 files changed

+15
-20
lines changed

7 files changed

+15
-20
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ RequireJS
2323
In our case, jquery.blockUI was being brought in manually, and it was
2424
using define() to add itself as a module. But, I believe you can't do
2525
this - it's being brought in too early (or something)
26-
- bower install requirejs-domready --save
26+
- bower install requirejs-domready --save
27+
- organized things into pages and modules

src/Yoda/EventBundle/Resources/views/Event/new.html.twig

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{% extends 'EventBundle::layout.html.twig' %}
22

3-
{% block javascripts %}
3+
{% block requirejs %}
44
{{ parent() }}
55

6-
<script src="{{ asset('assets/js/NewEventApp.js') }}"></script>
7-
8-
<script>
9-
jQuery(document).ready(function() {
10-
new NewEventApp($('.event-edit'));
11-
});
12-
</script>
6+
{{ include('EventBundle::_requirejs.html.twig', {
7+
'data_main': 'app/event_new'
8+
}) }}
139
{% endblock %}
1410

1511
{% block body %}

web/assets/js/app/event_new.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
define(['jquery', 'domReady!', 'app/modules/event_new_form'], function ($, doc, EventNewForm) {
2+
var eventsNew = new EventNewForm($('.event-edit'));
3+
});

web/assets/js/app/homepage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
define(['jquery', 'domReady!', 'app/modules/events_edit'], function ($, doc, EventsEdit) {
1+
define(['jquery', 'domReady!', 'app/modules/events_inline_edit'], function ($, doc, EventsEdit) {
22
var eventsEdit = new EventsEdit($('.events'));
33
});

web/assets/js/NewEventApp.js web/assets/js/app/modules/event_new_form.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
/**
2-
* Application for the new event form page
3-
*/
4-
(function($, window, undefined){
5-
1+
define(['jquery', 'bootstrap'], function ($) {
62
var app = function($eventsWrapper) {
73
this.$wrapper = $eventsWrapper;
84

@@ -11,7 +7,6 @@
117

128
$.extend(app.prototype, {
139
initialize: function() {
14-
console.log(this.$wrapper);
1510
this.$wrapper.on('submit', '.js-event-form', $.proxy(this._handleFormSubmit, this));
1611
},
1712

@@ -50,6 +45,5 @@
5045
}
5146
});
5247

53-
window.NewEventApp = app;
54-
55-
})(jQuery, window);
48+
return app;
49+
});

web/assets/js/common.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ requirejs.config({
1010
paths: {
1111
app: 'app',
1212
domReady: '../vendor/requirejs-domready/domReady',
13-
jquery: '../vendor/jquery/jquery.min'
13+
jquery: '../vendor/jquery/jquery.min',
14+
bootstrap: '../vendor/bootstrap/dist/js/bootstrap.min'
1415
}
1516
});

0 commit comments

Comments
 (0)