V
V
Vadim2014-12-10 02:23:45
JavaScript
Vadim, 2014-12-10 02:23:45

What to do with JS which is used in View in ZendFramework2?

There is the following View structure in the ZF2 module.

<div class="row">
  <div class="col-md-7">
    <table id="grid_customer"></table>
    <div id="pager_customer"></div>
  </div>
  <div class="col-md-5">
    <table id="grid_calls"></table>
    <div id="pager_calls"></div>
  </div>
</div>
<script type="text/javascript">
Использование JS для загрузки информации(ajax) и так далее,
который используется на этой странице.
</script>

I do not like the fact that js is present in the view. About 200 lines of code.
How to properly organize this JS?
- Transfer to a separate file and connect?
- Create a common file of all JS and include it in the main Layout?
- Is there anything wrong with having JS code in a view?
PS: Maybe someone has an example of a project developed on Zend2? For example on github or somewhere else? I would like to look at the organization of everything in a real project in order to understand how bad or good things are with me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
asdz, 2014-12-10
@asdz

It seems to me that this is not so scary: if this code is exclusively for this view, then you can leave it there, if it is possible to apply it in another view, then it is better to put it in a separate file and connect it in the desired view. If this code is used in many or all views, then it probably makes sense to include it in the parent view.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question