How do I access a variable from a different view?
I want to access selectedColor
in another view:
'onClickColor': function(e) {
var view = this,
selectedColor = $(e.currentTarget).data('color'), //$(this).data('color');
style = $('<style>.highlight { color: ' + selectedColor +'; margin-left: 4px;}</style>');
$('.initial').css('color', selectedColor);
$('.highlight').css('color', selectedColor);
$('html > head').append(style);
//view.canvasColorPick(e);
},
And then in another view, I want to pass the variable selectedColor using ajax on a form submission.
'formCollect' : function (e) {
var view = this;
var fname = $('#your_name').val();
var email = $('#email').val();
var state = $('#state').val();
var color = selectedColor;
var url = 'services/users/add?name='+fname+'&email='+email+'&state='+state+'&color='+color+'';
$.get(url);
},