lundi 10 octobre 2016

How to create html with link-to property inside custom jquery plugin?

I have a custom jquery plugin that use to create drop down html for a search box. Inside that, html is created as follows.

$.each(stack, function (i, stackItem) {
                    var url = _getItemURL(stackItem, lang);

                    if (stackItem.INS !== undefined) {
                        html += '<li class="row"> <a href="' + url + '">' + stackItem.DS_HIGHLIGHTED + ' - ' + stackItem.E + '<br>' + stackItem.TICKER_DESC + '</a> </li>';
                    } else {
                        html += '<li class="row"> <a href="' + url + '">' + stackItem.COMPANY_DESC_HIGHLIGHTED + '<br>' /*+ _getCountry(stackItem.CC, lang)*/ + '</a> </li>';
                    }
                    itemCount++;
              });

As you can see href attribute is used to create links in this html. But when user click on those links application reloads the browser page. I want it to correctly map to different route in the application like in hbs files as follows

<li> Stock </li>

How can I generate html like that inside previous java script code.

Appreciate any help?




Aucun commentaire:

Enregistrer un commentaire