I see that dust.js has #jsControl helper. Reference http://www.slideshare.net/veenabs/curious-case-of-dust Slide #29. I would like to know what it is and when and where to use. And I dont find the implementation of it in https://github.com/linkedin/dustjs-helpers/blob/master/lib/dust-helpers.js
Looks like, its a helper used internally at linkedin, which is used to attach javascript to given element. https://github.com/smfoote/Swiffer.js/issues/12
Related
Say I create an HTML file with two .page on it. In the first .page, I'd like to have a link to the second .page.
Is there a way to navigate between pages without having to write my own JS? This seems to suggest I do have to write JS: http://view.jquerymobile.com/1.3.2/dist/demos/widgets/navigation/.
However, I'd would rather set an id attribute for one of the pages, then maybe define some data attribute in the link to tell jQuery mobile where to go. Possible?
I'd also like to specify what kind of transition effect to use.
You can use standard anchor links, just give an id to your page and set the transition via the data attribute
Link to Page 2
I have a form_for in all of my views. Now I need to insert a hidden html input element in all of these views.
Is there anyway I could specify a wrapper over form using partials where I take all the form parameters , do my own logic of inserting the hidden input element and render the rest of the block given by the views? How can I do this?
Yes, I think you can write your own logic in views through helpers, Helpers provide you more flexibility, consistency, and also provide functionality to keep your code DRY(the basic feature of Rails). you can write your helper methods in app/helpers/application_helper.rb.
You can have a look on this guide:
http://guides.rubyonrails.org/form_helpers.html
Hope it will help you in what you were looking for.Thanks
is there any way (or plugin) to display editable combobox? I have a set of options, but I would like to give possibility to enter custom value.
I've searched the documentation, and I can't find way to do this. I made workaround with javascript, but I'm looking for more elegant solution.
I'm pretty sure that there simply is no HTML form element that does this, and so Rails can't provide you with a helper. As you said, you can work with JS to create something similar (and there should be JS libraries/plugins already out there), or you could just use a select element and add a text field next to it for new values.
HTML5 specification doesn't define such an element. So you may either continue using JS, either try to use autocomplete feature of an input element (although it is not exactly what you want and doesn't compatible with old browsers).
Hi I'm working with a project (asp.net mvc) where I need to show pictures on one site. They gone have jquery and be surrounded by a div like <div><img/></div>
I'm relatively new on MVC so I'm not sure what ways are the best to work in it yet. Should I do a ImageHelper so i can access it like <% Html.ImageJquery() %> or should i just do it plain in the view
what are your thoughts on this?
I am not sure if there is any single best practice for this case. As you already said you could create an extension method on a HtmlHelper or just put the code in the view.
Because the "added" code is a very simple (just two divs) I would skip extension method and just add the divs in the view. But if the code is actually more complex I would create a helper.
Cheers!
It depends how often you would use the helper. If it is used in a couple of places it would make sense, because it helps you to reduce redundant code.
The other option you have are partials.
I would go with an Extension method on the HTMLHelper , so that it accepts the 'src' value as a parameter and constructs the image tag accordingly.
Regarding Rendering of UI elements , i did read a blog post on 'Conditional Rendering' which i thought you would find it interesting .
please check the link below .
Conditional Rendering
Thanks ,
Vijay.
I have a submit button that is a block of HTML code because of styling and images to make it look better. (I stole most of it from Wufoo).
This is one every form in the application and I was wondering if there is a cleaner way to do this. Something like a partial or helper?
The name of the button "Submit" or "Add Contact" needs to be a variable.
snippet
Add Contact #variable text
Back
* Required
You can use a application-wide helper for this. Helpers are modules containing methods that are shared by multiple views. You can easily define your own helper that works like the 'submit_tag' helper method that generates the button.
consider partials (http://api.rubyonrails.org/classes/ActionView/Partials.html)
Seems like something partials were invented for.