Solution to referencing model attribute within javascript