Welcome Guest, Not a member yet? Register   Sign In
Javascript rendered in view fragments?
#1

[eluser]marlar[/eluser]
Hi,

In another thread I asked for recommendations on javascript libraries for rich user interfaces.

While I have not yet decided which one to go for, I have thought of a way to implement the scripts such that I can later change the library with little or no changes to the main views.

Let's say I need a popup menu somewhere which shows a list of choices for the user. Instead of hardcoding the javascript/dhtml into the view, I could instead inject the code either via a PHP variable initialized in the controller, or directly from a sub view (for example using the View Library or similar).

Then the controller or the sub view is responsible for generating the code for the popup menu. If I later change the library, I only need to modify the code centrally.

As a complete beginner with CI I might miss some important points, but does such a scheme seem wise?

Also, should it perhaps be a job for the model to deliver the html/javascript for the widgets? I know it is recommended that the models don't render the html, but this might be a special case.

Finally, can a model call another model? If so, the first model could deliver the raw data (which might be needed for other purposes) and the second model could render the code.

Regards,
Martin


Messages In This Thread
Javascript rendered in view fragments? - by El Forum - 12-12-2007, 03:50 PM
Javascript rendered in view fragments? - by El Forum - 12-12-2007, 04:55 PM
Javascript rendered in view fragments? - by El Forum - 12-12-2007, 05:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB