How to submit an HTML form so that it triggers a route in Backbone.js? -
i building tabbed wizard ui in backbone.js , use html form submission trigger route displays view next tab. however, usual submit button doesn't seem cause route fire.
index.html:
<form id="statesearch"> <fieldset> <legend>select state:</legend> <select name="statesearchname"> <option value="nd">north dakota</option> <option value="ok">oklahoma</option> <option value="tx">texas</option> <option value="wy">wyoming</option> </select> <button type="reset" name="submitstatename" onclick="window.location.href='index.html/#searchbystate'">search </button> </fieldset> </form>
app.js:
window.tabexrouter = backbone.router.extend({ routes: { '': 'home', 'searchbystate': 'searchbystate' }, .... )};
i know how build using jquery not backbone. suspect if create listener ordinary button , have listener navigate url cause route fire. but, seems tedious 6-8 tabs.
i have tried both type="reset" , type="submit" + event.preventdefault() in javascript same result.
is there canonical pattern in backbone?
Comments
Post a Comment