I’m using this jquery plugin to build forms.
In order to allow the modification of a form, I’m trying to load the json for a specified form, previuosly saved on a database.
I have to use
<script>
$(function(){
$('#my-form-builder').formbuilder({
'save_url': 'jsp/save.jsp',
'load_url': 'jsp/load.jsp',
'useJson' : true
});
$(function() {
$("#my-form-builder ul").sortable({opacity: 0.6, cursor:'move'});
});
});
</script>
but I need to have a ‘load_url’ with a query string, e.g. ‘jsp/load.jsp?id=11’, where the id is the identifier of the form in the database.
The formbuilder function should be called when user clicks on a ‘Modify form’ link or when a div loads.
I tried to use:
<script>
$('modify').click(function(){
var url = 'jsp/load.jsp?id='.$(this).id;
$("#".$(this).id).formbuilder({
'save_url': 'jsp/example-save.jsp',
'load_url': url,
'useJson' : true
});
$(function() {
$("modify ul").sortable({opacity: 0.6, cursor:'move'});
});
});
</script>
with:
<a href="index.jsp?id=${form.id}" id="${form.id}" class="modify">Modify form</a>
but it doesn’t work.
JavaScript uses
+to concatenate strings, not..You’ll also need to use
attr()to grab theid.Change this line:
var url = 'jsp/load.jsp?id='.$(this).id;It should be:
var url = 'jsp/load.jsp?id='+$(this).attr('id');