开发者

Auto completes in codeigniter

I have lots of auto completes like City, country, companies, brands, people names, etc. Now my team is currently giving each autocomplete a separate model in codeigniter. The issue i have is then each autocomplete has its own code. I want to make it temp开发者_StackOverflow中文版latized so there is only 1 code base for all auto completes and it pulls the autocompletes in and out dynamic.

Is it possible or is the way my team is doing it the correct way?


Your CI models should be organized to reflect your domain, so in the case of cities, countries, companies and such, each are different entities and deserve a seperate model. More files does not mean it is less maintainable.

As for autosuggest, your model simply needs to deliver the data to a controller that will be called using Ajax. You can do the json_encoding of the data stream in the model or the controller, I prefer to use the controller.

So eventually yoiu hopefully have a single autosuggest plugin in the front-end that simply calls different controller URLs. These controllers know which model to use to get the autosuggest data.

This is a clean seperation of duties, and maintainable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜